c++ program that display the patterns.
for n=4
pattern ::
abcd
abc
ab
a
#include<iostream.h>
#include<stdio.h>
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;
}
No comments:
Post a Comment