Professional Documents
Culture Documents
Lab
Lecture 07
int counter ;
for( counter = 0 ; counter < 10 ; counter = counter + 1 )
cout << counter;
Output
0123456789
2x1=2
2x2=4
2x3=6
:
:
2 x 10 = 20
main ( )
{
int counter ;
for ( counter = 1 ; counter <= 10 ; counter = counter + 1 )
{
cout << "2 x " << counter << " = " << 2* counter << "\n“ ;
}
}
2 x1 = 2
2x2=4
2x3=6
:
:
2 x 10 = 20
Using For loop write a program in C++ to find the sum of first 10 natural numbers.
e1 op= e2
where e1 is a modifiable l-value not of const type and e2 can be :
An arithmetic type
A pointer, if op is + or -
It works same as e1 = e1 op e2
Syntax
Write a program to print Tables from 5 to 10 on screen using nested for loop
Write a program in C++ to display the pattern like right angle triangle with number.
1
12
123
1234
12345
*
**
***
****
Write a program in C++ to make such a pattern like a pyramid with an asterisk.
Hint: pyramid having odd number of asterisk.
*
***
*****
*******