Monday, December 24, 2012

DIAMOND SHAPE STAR PRINTING IN C++


#include <iostream.h>
void main()
{
int i,j,k;
for( i = 10; i >= 1; i-- )
{
for( j = 1; j < i; j++ )
{
cout << " ";
}
for( k=10; k >= j*2; k-- )
{
cout << "*";
}
cout << "\n";
}
for( i = 2; i <= 10; i++ )
{
cout << " ";
for( j = 2; j < i; j++ )
{
cout << " ";
}
for( k = 10; k >= j * 2; k-- )
{
cout << "*";
}
cout << "\n";
}
}

No comments: