PROGRAM TO PRINT PYRAMIDS IN C++
PROGRAM #1
#include<iostream.h>
#include<conio.h>
void main()
{
int k,n=5;
clrscr();
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if (j==i)
{
cout<<"1";
}
else
{
cout<<"2";
}
}
cout<<"\n";
}
getch();
}
PROGRAM #2
#include<iostream.h>
#include<conio.h>
main()
{
int n=3;
clrscr();
for (int i=0;i<n;i++)
{
for(int k=0;k<i;k++)
{
cout<<" ";
}
for(int j=n-i;j>0;j--)
{
cout<<"*";
}
cout<<"\n";
}
getch();
}
PROGRAM #2
#include<iostream.h>
#include<conio.h>
main()
{
int n=3;
clrscr();
for (int i=0;i<n;i++)
{
for(int j=n-i;j>0;j--)
{
cout<<"*";
}
cout<<"\n";
}
getch();
}
PROGRAM #3
#include<iostream.h>
#include<conio.h>
main()
{
int n=5;
clrscr();
for (int i=0;i<n;i++)
{
for(int k=0;k<i;k++)
{
cout<<" ";
}
for(int j=n-i;j>0;j--)
{
cout<<"* ";
}
cout<<"\n";
}
getch();
}
PROGRAM #4
#include<iostream.h>
#include<conio.h>
main()
{
int n=4;
clrscr();
for(int i=0;i<n;i++)
{
for(int j=0;j<n-i;j++)
{
cout<<" ";
}
cout<<"*";
for(int k=0;k<i;k++)
{
cout<<" *";
}
cout<<"\n";
}
getch();
}
I like it
ReplyDeletethese are quite understable ........... plz post more like these
ReplyDeleteThese are supposed to be hard?
ReplyDelete