Friday, 2 April 2021

Pattern in C++

 #include<stdio.h>

#include<iostream.h>

#include<conio.h>

main()

{

clrscr();

/*int i, j;

for(i=1;i<=5;i++)

{

for(j=1;j<=i;j++)

{

cout<<j;

}

cout<<endl;

} */


int i=65,x=1,m=70,j,s=2;

while(x<=7)

{

while(i<=m)

{

cout<<(char)i;

//printf("%c",i);

i++;

}

i=i-1;

if(x!=1)

{

j=1;

while(j<=s)

{

cout<<" ";

j++;

}

s=s+2;

}

while(i>=65)

{

cout<<(char)i;

i--;

}

cout<<endl;

x++;

i++;

m--;

}

getch();

return 0;

}

No comments:

Post a Comment