# Adel bebawy 1050-Test01 midterm - Cuyahoga Community...

• Test Prep
• 21

This preview shows pages 1–10. Sign up to view the full content.

Cuyahoga Community College Fall Semester 2016 1050 Programming Logic Dr. Kevin Landis Test 1 (midterm) Adel Bebawy 11/16/2016

This preview has intentionally blurred sections. Sign up to view the full version.

points per problem – 48 points 1-Create an infinite while loop. Use a Boolean variable called keepLooping that set to true in the loop’s termination condition. Hint: Use CTRL+C or Debug -> Terminate All to end the program.

This preview has intentionally blurred sections. Sign up to view the full version.

2- Write a while loop to prints 1 through6 in square brackets: [1] [2] [3] [4] [5] [6]
3- Write a for loop that computes the sum of first n positive integers. Set the variable n to 12. Print “The sum of all integers from 0-12 is “ + sum sum = 1 + 2 + 3 + … + n

This preview has intentionally blurred sections. Sign up to view the full version.

4- Write a for loop that prints 1 through n, separated by commas. Example: for n = 9 print 5- 1, 2, 3, 4, 5, 6, 7, 8, 9
5- Write a while loop that prints all even numbers 0 through n, separated by commas. Example: for n = 20 print 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20

This preview has intentionally blurred sections. Sign up to view the full version.

6- Write a while loop that prints all odd numbers 1 through n, separated by commas. Example: for n = 15 print 1, 3, 5, 7, 9, 11, 13, 15
7- Given the following code, For n = 7 what is the output?

This preview has intentionally blurred sections. Sign up to view the full version.

This is the end of the preview. Sign up to access the rest of the document.
• Fall '14
• loop, Do while loop

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern