Code of the program:
#include<iostream>
using
namespace std;
int
main()
{
cout<<"\t<<<<<
Program to Print Pascal Triangle >>>>>"<<endl;
int i, j, k;
for(i=1;i<=5;i++)
{
for(j=i;j<5;j++)
{
cout
<< " ";
}
for(k=1;k<(i*2);k++)
{
cout << "*" ;
}
cout <<endl;
}
return 0;
}
Output:
Code#2:
#include<iostream>
using namespace std;
int main()
{
cout<<"\t<<<
Program to print star reverse Pascal Triangle"<<endl;
int i, j, k;
for(i=5;i>=1;i--)
{
for(j=5;j>i;j--)
{
cout << " ";
}
for(k=1;k<(i*2);k++)
{
cout << "*";
}
cout <<endl;
}
return 0;
}
Output:
No comments:
Post a Comment
Tell me What can I do for you.....Comment, please