11/10/2016CS150 Introduction to Computer Science 1 Last Time We covered “for” loops
21/10/2016CS150 Introduction to Computer Science 1 Localized Declarations for (int i = 0; i < n; i++) cout << i << endl; i is declared ONLY in the loop
31/10/2016CS150 Introduction to Computer Science 1 Rewrite using a while loop for (i = 5; i < 10; i+= 2) cout << i; What does this output?
41/10/2016CS150 Introduction to Computer Science 1 Formatting Output How can we generate this output? Fahrenheit Celsius
51/10/2016CS150 Introduction to Computer Science 1 The Program float F,C; F = 32.0; cout << fixed << setprecision(3); cout << "Fahrenheit"; cout << "Celsius" << endl; while (F <= 212.0) { C = (5.0/9.0)*(F - 32); cout << setw(10) << F << setw(12) << C << endl; F += 1; } You must have #include
61/10/2016CS150 Introduction to Computer Science 1 Programs Write a program that will print the sum of the odd integers between 1 and 50 inclusive. Write one program using a while and the other using a for loop.
71/10/2016CS150 Introduction to Computer Science 1 Program Write a program that inputs 50 numbers and outputs the largest and the smallest number
81/10/2016CS150 Introduction to Computer Science 1 Conditional Loops Loops that execute until some condition is met Includes more than counting Use while loops
91/10/2016CS150 Introduction to Computer Science 1 Program Write a flag controlled loop that continues to read pairs of integers until it reads a pair with the property that the first integer is evenly divisible by the second