
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Below are four code segments, including a variable initialization and a loop. Write the value that the requested variable contains after the loop has completed.
int n, m; n = 1; for ( m = 1; m <= 5; m++ ) { n = n*m; }
What is n?
double x, y; x = 64.0L; do { y = sqrt(x); } while ( y > 10 );
What is y?
int a, b; a = 5; while ( a < 100 ) { b = a+2; a = b * a; }
What is b?
int e = 1, f = 1, g; for ( g = 0; g < 10; g++ ) { int temp = f; e = f; f = temp + e; }
What is f?
Download loops.zip from the lecture outline. Expand it into your Z: drive and open loops.c. There are blanks in the implementations of the functions squares and exponents where you need to insert a loop structure.
To check your work, type the command testLoops. This will run your program with the input 20 2.
Bonus: Write the exponents function without using the pow function. Show the instructor your code if you have done the bonus.