My Asterisk code
Posted by mark123
Last Updated: September 20, 2012
#include"stdafx.h"// Visual C++ precompiled header.
#include<iostream>
#include<cstdlib>
using namespace std;
int main()
{
int i,j;
int num;
i=0;//initialize loop controller.
while(i<5)//while loop for five entries
cout<<"Please enter a number:"<<endl;
cin>>num;
if(num<1||num>20)//error testing if statement.
{
     cout<<"Error!!!Please enter a value between 1 and 20.Please try again:"<<endl; 
cin>>num;
}
if(num%2==0)//test if num is even.
{
      for(j=0;j<num;j++)
 {
        cout<<"*";
 }


}
if(num%2==1)//test if num is odd.
{

     for(j=0;j<num;j++)
{
cout<<"#"; 
}

}
i++;//increments loop each time it goes through.
}
system("pause");
return 0;
}
Related Content