Respuesta :
The program what will read a number followed by a series of bit operations from file and perform the given operations sequentially on the number is given below.
What is an operation in computer science?
An operation, in mathematics and computer programming, is an action that is carried out to accomplish a given task.
There are five basic types of computer operations:
- Inputting,
- processing,
- outputting,
- storing, and
- controlling.
What is the requested program above?
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
int number, n, v, temp;
char line[25], fun[10];
FILE *f = fopen(argv[1], "r");
fgets(line, 24, f);
sscanf(line, "%d", &number); //reading the number
while( fgets(line, 24, f) )
{
sscanf(line, "%s %d %d", fun, &n, &v); //reading the commands
switch(fun[0]) //checking which command to run
{
case 'g': temp = 1;
temp = temp<<n; //shifting for getting that bit
printf("%d\n",(number&temp)&&1);
break;
case 's': temp = 1;
temp = temp<<n; //shifting for setting that bit
if(!v)
{
temp = ~temp;
number = number & temp;
}
else
{
number = number | temp;
}
printf("%d\n",number);
break;
case 'c': temp = 1;
temp = temp<<n; //shifting for complimenting that bit
number = number ^ temp; //xor to complement that bit
printf("%d\n",number);
break;
default:printf("not defined");
}
}
return 0;
}
Execution and Output:
terminal-> $ gcc -o first first.c
terminal-> $ ./first file1.txt
1
4
6
Learn more about programs at;
https://brainly.com/question/16397886
#SPJ1