"The best way to cheer yourself up is to try to cheer somebody else up." Mark Twain

Thursday, March 4, 2010

Write a program using nested loops to produce the following design:

A
A B
A B C
A B C D
A B C D E


#include<iostream.h>
#include<conio.h>

void main()
{
char ch='A';

int n;
cout<< "\n Enter the height of the triangle :";
cin>> n;
for(int i=1; i< = n ; i++)
{
ch = 'A';
for(int j = 1; j< = i; j++)
{
cout<< ch<< " ";
ch++;
}
cout<< "\n";
}

getch();
}

No comments:

Post a Comment

C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.
Now Playing: Ballade Pour Adeline

About Me

My photo
I m an IT lecturer of a college. I love social-work. I want to do something beneficial for society before dying , that can promote our society, to some extent.