Question: this is the first part here: ( im looking for the next parts, given in the picture. please solve the whole question, do not give

this is the first part here:(im looking for the next parts, given in the picture. please solve the whole question, do not give a half reply please
#include
#include
// Global enum for the type of initialization
enum initTypeList { Random =1, Checkerboard, AllWhite };
// Function to read input from the file
int readInput(const char *filename, int *numRows, int *numCols, int *numRobots, int *initTypeValue, unsigned int *initSeed, int *numTurns, int *interval, char *outputFilename){
FILE *file = fopen(filename,"r");
int numScanned = fscanf(file,"%d %d %d %d %u %d %d %s", numRows, numCols, numRobots, initTypeValue, initSeed, numTurns, interval, outputFilename);
fclose(file);
if (numScanned !=8){
fprintf(stderr, "ERROR: Input file not opened correctly.
");
return 0;
}
if (*numRows 20||*numRows >300){
fprintf(stderr, "ERROR: The number of rows was outside the specified range (20 to 300 inclusive).
");
return 0;
}
if (*numCols 20||*numCols >300){
fprintf(stderr, "ERROR: The number of columns was outside the specified range (20 to 300 inclusive).
");
return 0;
}
if (*numRobots 1||*numRobots >10){
fprintf(stderr, "ERROR: The number of robots was outside the specified range (1 to 10 inclusive).
");
return 0;
}
if (*initTypeValue 1||*initTypeValue >3){
fprintf(stderr, "ERROR: The initTypeValue was outside the specified range (1 to 3 inclusive).
");
return 0;
}
if (*initSeed 10||*initSeed >32767){
fprintf(stderr, "ERROR: The initSeed was outside the specified range (10 to 32767 inclusive).
");
return 0;
}
if (*numTurns 10||*numTurns >5000){
fprintf(stderr, "ERROR: The number of turns was outside the specified range (10 to 5000 inclusive).
");
return 0;
}
if (*interval 1||*interval >*numTurns){
fprintf(stderr, "ERROR: The printing interval was outside the specified range (1 to number of turns inclusive).
");
return 0;
}
return 1;
}
int main(){
char filename[100];
printf("Enter the name of the input file: ");
scanf("%s", filename);
int numRows, numCols, numRobots, initTypeValue, numTurns, interval;
unsigned int initSeed;
char outputFilename[100];
int attempts =0;
while (!readInput(filename, &numRows, &numCols, &numRobots, &initTypeValue, &initSeed, &numTurns, &interval, outputFilename)){
attempts++;
if (attempts >=5){
fprintf(stderr, "ERROR: Failed to open the input file 5 times. Terminating the program.
");
return 1;
}
printf("Enter the name of the input file: ");
scanf("%s", filename);
}
printf("Input read successfully!
");
printf("Number of Rows: %d
Number of Columns: %d
Number of Robots: %d
Initialization Type: %d
Seed: %u
Number of Turns: %d
Printing Interval: %d
Output Filename: %s
",
numRows, numCols, numRobots, initTypeValue, initSeed, numTurns, interval, outputFilename);
return 0;
}
 this is the first part here:(im looking for the next parts,

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!