Sunday, December 6, 2009

C++->SERIES FOR n ROWS

Write a program to print the following series for n rows.

a
a b
a b c
a b c d
. . . nth row. . .

#include
#include
void main()
{
int i,j,l,n;
char ch;
clrscr();
cout<<”Enter how many lines : “;
cin>>n;
l=40;
for(i=1;i<=n;i++)
{
for(j=1;j<=n;j++)
cout<<” “;
for(j=1,ch=’a’;j<=I;j++,ch++)
cout<<” “< l=l-1;
}
getch();
}

0 comments:

Post a Comment

Followers