Hi if someone could answer this question it has to be in C n
Hi if someone could answer this question it has to be in C, not C++ or C# just C. Thank you! the actual text files dont need to be done I can do those, just the rest of the program. Thanks!
Create a file called numInput.txt and put at least 3 integers in the file.
 Save the file in the same directory as your source code in your project.
 Create an interactive program that reads an integer from the file called numInput.txt, performs a calculation, and stores the result in a different file called AnswerOut.txt.
Declare your variables.
Open two files:
numInput.txt, to be used for “reading from”
 AnswerOut.txt, to be used for “writing to”
Inside a loop that will run 3 times
use fscanf to read an integer from this file.
prompt the user for a type double value.
Multiply the double entered by the user by the integer from the file, and store the result in a double.
Use fprintf to write the results of the multiplications to the file AnswerOut.txt.
To verify your code works, find the AnswerOut.txt file. There should be three values in the file.
THIS DOES NOT REQUIRE A USER DEFINED FUNCTION - NOTE: Every time you test this program you should find only the last set of calculated values. The file will NOT retain old information once it has been re-run.
Solution
#include <stdio.h>
 int main()
 {
 int num;
 double userInput,result;
/* Pointer for both the file*/
 FILE *fpr, *fpw;
 /* Opening file numInput.txt in “r” mode for reading */
 fpr = fopen(\"numInput.txt\", \"r\");
/* Ensure numInput.txt opened successfully*/
 if (fpr == NULL)
 {
 puts(\"Input file is having issues while opening\");
 exit (0);
 }
/* Opening file AnswerOut.txt in “w” mode for writing*/
 fpw= fopen(\"AnswerOut.txt\", \"w\");
/* Ensure AnswerOut.txt opened successfully*/
 if (fpw == NULL)
 {
 puts(\"Output file is having issues while opening\");
 exit (0);
 }
 printf(\"Enter the double value:\");
 scanf(\"%lf\",&userInput);
while (fscanf(fpr, \"%d\", &num)!=EOF)
 {
result=userInput*num;
 fprintf(fpw,\"%lf \", result);
}
 /* Closing both the files */
 fclose(fpr);
 fclose(fpw);
return 0;
 }
numInput.txt
2 3 4
AnswerOut.txt
6.400000 9.600000 12.800000
OUTPUT:
Enter the double value:3.2


