New Pyramid Pattern - Try it code, working code in Turbo C++.
//New Pyramid Pattern - Try it code, working code in Turbo C++.
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int i,j,n;
clrscr();
cout<<"Enter Number :";
cin>>n;
for(i=1;i<=n*2;i++)
{
for(j=1;j<=n*2;j++)
{
if(i+j<=n*2)
{
cout<<" ";
}
else if(i<=n && i+j>=n*2+1 || i>=n && j<=n && i+j>=n*2+1 || j>=n && i+j>=n*3+1)
{
cout<<setw(4)<<"*";
}
else
{
textcolor(13+BLINK);
cprintf("%4c",'.');
// cout<<setw(4)<<".";
textcolor(7);
}
}
cout<<endl;
}
getch();
}
Output:
Enter Number :5
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
int i,j,n;
clrscr();
cout<<"Enter Number :";
cin>>n;
for(i=1;i<=n*2;i++)
{
for(j=1;j<=n*2;j++)
{
if(i+j<=n*2)
{
cout<<" ";
}
else if(i<=n && i+j>=n*2+1 || i>=n && j<=n && i+j>=n*2+1 || j>=n && i+j>=n*3+1)
{
cout<<setw(4)<<"*";
}
else
{
textcolor(13+BLINK);
cprintf("%4c",'.');
// cout<<setw(4)<<".";
textcolor(7);
}
}
cout<<endl;
}
getch();
}
Output:
Enter Number :5
No comments
Post your comments