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

Thursday, March 4, 2010

Write program using nested loops to produce the following design:

& & & & &
   & & &   
       &      


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

void main()
{
int n;

clrscr();
cout<<"\n Enter height of a triangle :";
cin>>n;

for(int i = n, sp = 0; i >0 ; i --, sp++)
{
for(int k=0; k<=sp; k++)
cout<<" "<<" ";

for( int j = 1; j <  2*i ;  j++)
{
cout << "&" << " ";
}

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.