Write a program to print the following output using loop:
Solution:
#include<iostream.h>
#include<conio.h>
void main()
{
int i, j, s;
clrscr();
for(i = 1; i<= 5; i++)
{
for(s =1; s<= 5-i; s++)
cout<<"\t";
for(j = 1; j <= i; j++)
cout<<"\t"<<j;
cout<<"\n";
}
getch();
}
No comments:
Post a Comment