Thursday, 24 November 2016

Star Pattern Diamond



 this program help you in creating different star pattern.
diamond created when user enter odd number not even
#include <iostream>
using namespace std;
int main ()
{
    int space,line,rows,start;
    cout <<"Enter number of rows want display  " <<endl;
    cin >>rows;
    while (rows%2==0)
    {
        cout <<"rwos number  must be odd re enter number of rows"<<endl;
        cin >>rows;
    }
    for (line=1; line<=rows; line=line+2){
        for (space=1; space<=rows-line; space=space+2){
            cout <<' ';
        }for (start=1; start<=line; start++){
            cout <<"*";
        }
        cout <<endl;

}
    int row;
    row=rows-2;
    for (line=row; line>=1; line=line-2){
        for (space=1; space<=rows-line; space=space+2){
            cout <<' ';
        }for (start=1; start<=line; start++){
            cout <<"*";
        }
        cout <<endl;

}
   
    return 0;
}

No comments: