
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Information about lab assignment 5 for csce 150a - problem solving using computers course, which was offered in spring 2009. The assignment includes four problem-solving exercises related to loops. Students are required to write the value of the variable after the loop has completed for each problem.
Typology: Assignments
1 / 1
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.