Thursday, November 20, 2014
C++ Program for printing Inverted Isosceles triangle
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
int N;
cout << "Enter any number for base of Isosceles trianlge: ";
cin >> N;
while( N<=0 || N%2==0 )
{
cout << "Wrong Input! Enter again: ";
cin >> N;
}
int space,
triangle;
space = triangle = N;
for(int i=1 ; i<=N ; i+=2)
{
cout << setw(space);
for( int j=1 ; j<=triangle ; j++)
cout << "*";
cout << endl;
space +=1;
triangle -=2;
}
return 0;
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment