Tuesday, November 26, 2013

Star Pyramid with for loop




 >>>>>>>>>>THE CODE<<<<<<<<<<<<<<<<
 
#include <iostream>
using namespace std;
void main()
{
    int row;
    cout<<"Enter number of rows"<<endl;
    cin>>row;
    row=row*2;
    int t=0;
//This loop controls the rows
    for(int y=0;y<row;y++)
    {
        y++;
//This loop controls the spaces
        for(int x=row;x>y;x=x-2)
        {
            cout<<" ";
        }
//This loop controls the stars in each row
          for(int z=0;z<y;z++)
        {
            cout<<"*";
        }
        cout<<endl;
   
    }

    //coded by cppfuzz.com

}

Widgets

 

Copyright @ 2014 CPP Fuzz.