Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C Program Create a file called numInput.txt and put some integers in the file. S

ID: 645468 • Letter: C

Question

C Program

Create a file called numInput.txt and put some 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 int from the file called numInput.txt, performs a calculation, and stores the result in a different file called resOut.txt.

1. Ask the user for a double.

2. Open a file called numInput.txt, and use fscanf to read an int from this file.

3. Multiply the double entered by the user by the int from the file, and store the result in a double.

4. Open a file called resOut.txt.

5. Use fprintf to write the result of the multiplication to the file resOut.txt.

Explanation / Answer

#include

main()
{
FILE *fp;
int buff;
double userData, result;

fp = fopen("numInput.txt", "r");
fscanf(fp, "%d", &buff);
fclose(fp);

printf(" Please enter a double ");
scanf("%lf",&userData);

result = userData*buff;

fp = fopen("resOut.txt", "a");
fprintf(fp,"%f ",result);
fclose(fp);
}

Please note: I assume, the problem description as to read Only 1 integer from the input file. If that is the case, then the program is working fine..Else more modification would be required...