c++
Name:
KCST ID:
CE-100 Introduction to Computer Systems
Tutorial - 6: Repetition Structures
OBJECTIVES: 1. Learn how to use repetition structures in C++ programs 2. Learn the different syntaxes of repetition structures. 3. Understand the concept of a "running total" variable. RULES: Hand write your answers, both flowchart and code, on a separate sheet of paper.
It is recommended to use pencil for drawing flowcharts.
Assignment Problems: Draw the flowchart and write C++ code to solve the following problems (Q1 to Q3)
Q1. Print the sum of the odd numbers between 10 and 206.
Q2. Input a number n print its multiplication table (from 1 to 10), i.e., n x 1, n x 2, … n x 10.
Q3. Enter the number of days n in a period of time. Your program should then ask the user
again to enter the n temperatures in those days, one by one. Finally, your program should
compute and print the average temperature for the given time period. Q4. What is the output of this program? [Write your answer inside this box] #include <iostream> using namespace std; int main() {
for (int i = 1; i > -3; i--) cout << i << " ";
return 0; }
Q5. What is the output of this program?
#include <iostream>
[Write your answer inside this box]
using namespace std; int main() {
int i = 1; while ( i > 0 ) {
i--; cout << i << " ";
} return 0;
}
Q6. What is the output of this program?
#include <iostream>
[Write your answer inside this box] using namespace std; int main() {
int i = 1; while ( i > 5 ) {
cout << i << " "; i++;
} return 0;
}
Q7. Fill in the blanks in this program so that its output be: -3 -2 -1
#include <iostream>
using namespace std;
int main() {
for ( ; ; i++)
cout << i << " ";
return 0;
}