Wap a program in c++ pattern 1 121 12321
Answers
Answered by
2
#include<iostream.h>
#include<conio.h>
void main()
{
int i, j, n = 5;
clrscr();
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
cout <<" "<<j ;
}
j -= 2;
for(; j>=1; j--)
{
cout <<" "<<j ;
}
cout << "\n" ;
}
getch();
}
#include<conio.h>
void main()
{
int i, j, n = 5;
clrscr();
for(i=1; i<=n; i++)
{
for(j=1; j<=i; j++)
{
cout <<" "<<j ;
}
j -= 2;
for(; j>=1; j--)
{
cout <<" "<<j ;
}
cout << "\n" ;
}
getch();
}
sahilbhilave:
this answer was in for loop
Similar questions