


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
CS 155 Exam Review Material Type: Notes; Professor: Jenkins; Class: Computer Science I; Subject: Computer Science; University: University of North Alabama; Term: Spring 2011;
Typology: Study notes
1 / 4
This page cannot be seen from the preview
Don't miss anything!
Name __________________________________
General Question – 25 points (5 points each):
Tracing One – Predict the output of the following code as it would appear on the screen – 25 points. #include
int main(){ int a = 2, b = 4, c = 6, d = 5; double e = 5.0;
cout << "PROB1: " << a + b / d << endl; cout << "PROB2: " << a + b / e << endl; cout << "PROB3: " << d + a * c % b << endl; cout << "PROB4: " << a + b++ << endl; cout << "PROB5: " << b << endl;
return 0; } Show output below:
Name __________________________________
Tracing Two – Predict the output of the following code as it would appear on the screen – 25 points. #include
int main(){ int x = 2; int res1 = 0; while (x < 12){ res1 = res1 + x; cout << "res1: " << res1 << endl; x = x * 2; } cout << "x: " << x << endl;
cout << "***********" << endl; int i = 1; int j;
int res2 = 0; while (i < 4){ j = 1; res2 = 0; while ( j < 5){ res2 = i * j; cout << res2 << " "; j++; } cout << endl; i++; }
return 0; } Show output below:
Name __________________________________
Coding Two– Write the entire program for the problem presented – 25 points.
Write a program that asks the user for a list of grades to be averaged. Ask for grades until the user enters a value less than 0 or greater than 100. The invalid entry should not be included in the average. Be sure to include descriptive prompts for input and descriptive explanations for output.
Sample Input: 90 91 100 80 75 - Sample Output: The average of 5 grades is: 87.
Neatly write your entire program: