#include<iostream.h>
void main()
{
cout<<"Number Square"<<endl;
for(int i=1;i<=5;i++)
{
cout<<i<<"\t"<<i*i<<endl;
}
}
output:
Number Square
1 1
2 4
3 9
4 16
5 25
for loop:
The for loop consist of three expression. The first expression is used to initialize the index value, the second to check whether or not the loop is to be continued again and the third to change the index value for further iteration.
for loop statement:
for(expression_1; expression_2; expression_3)
{
--------------;
--------------;
}
void main()
{
cout<<"Number Square"<<endl;
for(int i=1;i<=5;i++)
{
cout<<i<<"\t"<<i*i<<endl;
}
}
output:
Number Square
1 1
2 4
3 9
4 16
5 25
for loop:
The for loop consist of three expression. The first expression is used to initialize the index value, the second to check whether or not the loop is to be continued again and the third to change the index value for further iteration.
for loop statement:
for(expression_1; expression_2; expression_3)
{
--------------;
--------------;
}
No comments:
Post a Comment