Quiz 5 Solution - fclose(dataFile 4 long factorial(int k...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Name: _____________________________ Quiz Five 1) Complete the last statement to open a file ‘data.txt’ in the read mode. [2 points] int x; FILE *dataFile; dataFile = fopen(“data.txt”, “r”) ; 2) Write a C statement to read the value of x from the file. [2 points] fscanf(dataFile, “%d”, &x); 3) Write a C statement to close the above file: [2 points]
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: fclose(dataFile); 4) long factorial(int k){ if(k == 0) return 1; else return k * factorial(k-1); } int main(){ long x; x = factorial(2); return 0; } What is the value of x right before this program exits? [2 points] 2 How many times will the factorial function be called? [2 points] 3...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online