jayman9, on 19 Sep, 2007 - 11:13 PM, said:
Post the code that you have completed in your attempt to fulfill your assignment. We will not do your work for you.
PLEASE HELP!! same type of question programmed in C++.
I want to make a triangle of stars when the user inputs a number. that number inputted should be the length of the base and the height.
For example if user inputs 4:
*
**
***
****
my program when compiled (user enters 4) looks like:
*
**
1/2 of the rows it should be!! i stared at it for hours and just cant figure it out. help would be greatly appreciated.
my code is:
the restrictions i set on the input must be: positive even value between 0 and 21
__________________________________
#include <iostream>
using namespace std;
int main ()
{
int input =0;
do
{
cout<< "Input a number of rows on your triangle"<<endl;
cout<< "Enter -1 to exit"<<endl;
cin>>input;
}while(input<0 || input>21 || input%2 != 0);
int column=1;
int row = 1;
for (row = 1; row<=input; row++)
{
for (column= 1; column<=input; column++)
{
if(column<=row)
cout<< "*";
else
cout<< " ";
column++;
}
column=1;
row++;
cout<<endl;
}
system ("pause");
return 0;
}
i have a feeling its something small but i cant figure it out. please help as quick as possible :) thanks in advance
1) Always use code blocks
2) Always post in the correct forum!
I'm moving this to the C and C++ Forum
This post has been edited by PsychoCoder: 13 October 2007 - 05:48 AM

New Topic/Question
Reply




MultiQuote




|