Wednesday, January 18, 2012

A C++ Prgramme that will print a polygon of stars.


Out put will be like above stars:

Here is the code.

#include<iostream>
#include<iomanip>
using namespace std;

int main()
{
    int i, j, n=40;
   
    for(i=1; i<=40; i=i+2)
    {       
             cout<<endl<<setw(n);
             n--;
             for(j=1; j<=i; j++)
             cout<<"*";
                           
    }
     cout<<endl<<endl<<endl<<endl;
     system("pause");
     return 0;
}







No comments:

Post a Comment