Code:#include<iostream> using namespace std; int main(void) {//declaration of variables int num; //value of first integer int count; //value of second integer cout<<"Please enter an integer between 1 and 10"<<endl; //tells user to enter a number bet. 1-10 cin>>num; if (num<1 || num>10) //reenter if number is less than 1 or greater than 10 { cout<<" Please insert correct number"<<endl; cin>>num; } for(count=1; count<num; count+=2) // counting stars by 2 each time from beginning 1 to the number user entered { for(int num = 0; num < count; num++) cout<<"*"; cout<<endl; } for(count; count>0; count-=2) // subtraction stars by 2 each times from the num user entered to 1 { for(int num = 0; num < count; num++) cout<<"*"; cout<<endl; } system("PAUSE"); return 0; } somehow my printed diamond program doesn't work with even number i entered. anyone know what's wrong with it?



LinkBack URL
About LinkBacks


