Professional Documents
Culture Documents
for loop is an entry controlled looping statement. It is used to repeat set of statements
until some condition is met.
Syntax:
Example:
#include <iostream>
using namespace std;
int main()
{
int i;
}
}
Task 1: Write a complete C++ program that allows the user to print the following message
10 times. The message is “I can do it!”
Task 2: Write a complete C++ program that allows the user to enter 10 numbers. Your
program is able to calculate the total and average of these numbers. Display the total and
average to the user.
Task 3: Write a complete C++ program that allows the user to enter 10 numbers. Your
program is able to do the following tasks:
a. Calculate the number of even numbers;
b. Calculate the number of odd numbers;
Task 4: Input 10 integer numbers using a for loop, check if the number is positive, add the number
to a variable posNum, otherwise, add the number to a variable negNum.