Thursday, 28 June 2012

c++ program that display following triangle pattern.

for n=5;
pattern:
a b c d e
a b c d
a b c
a b
a

#include <iostream>
using namespace std;

int main()
{
int i,j,k;
char x;
//input from user
cout<<"Enter a number ";
cin>>k;




for(i=k;i>0;i--)
{
x=97;
for(j=1;j<=i;j++)
{

cout<<x;
x=x+1;
if(x>123)
{
x=97;
}
}
cout<<"\n";
}
return 0;
}