Question #2: The following program reads integer numbers from a file named numbers.tet. For each number, the program computes the reverse in order to check whether the number is a palindrome number or not. It then reports the results into a file named Report.txt (A palindrome is any autor whose reverse is also some es. 1721.23432. 7.8 are palindromex hur 23489 mot) Suppose the file numbers.txt contains the following numbers: 373 11 2552 5 3561 numbers.txt Study the program carefully and answer the below questions Hint: you might run the program before starting answering the questions! e) Show the output of the program. Assume that the file anches.tot contains the stata shown above As the program contains nested while loop, determine how many times the following statements will be executed: Assame that the file mums.txt contains the data shown above 11 inlile = fopen("numbers.txt". -times) 2) printf("dis read from the filen. number: times 3) digtemp 10: times) 4) printf("%d is a palindrome number in number: times) g) How many times does the program check the condition of the outer while loop, i.c., status IEOF? Assume that the file here tot contains the data shown above times) Page 4 of 7 #include
#include stdlib.h> int main(void) int number, reverse - 0, digt, temp: FILE infile.outfile: int status //open the input file and check if an error occurred infile = fopen("numbers.txt","7://open the input file iffinfile> NULL printf("Error: File numbers.txt" not foundin"); exit (1): > //open the output file and check if error occurred outfile = fopen("Report.txt","w foutfiles NULL printf("Error: File \"Report, bet\" can not be created in 1 status = fscanf(infile. ".&number): //read first number from the file whilestatus EOF //To read all the numbers in the file printf("%d is read from the file number); fprintf(outfile, "d", number): //compute the reverse of the number temp. number: reverse: while temp to digit temp X10 reverse reverse * 10digt: temp temp/10; printf("The reverse is: ", reverse): fprintf(outfile.80", reverse): //check whether the number is palindrome finumber == reverse printfd is a palindrome number ini", number fprintf(outfile." Palindrome "); 1 elsel printf"%d is not a palindrome numbert Win", number: fprintf(outfile. Non-Palindromen"); I/read another number from the file status = fscanf(infile. %d",&number): i/close the files fclose(infile: fclose(outfile: return 0; Page 5 of 7 a) What is the benefit of the statement temp = number for the program? What will happen if we eliminate it and use the variable number instead of temp in the inner while loop? Hint: Run the program with this modification and check the result! b) What is the purpose of the statement reverse = 0; in the program? What will happen if we didn't put it before the inner while loop? Hint: Run the program without this this statement and check the result