Hi there,
Let's break the assignment down:
Your program must work for any odd number entered by the user |
So the user should be able to enter a number, and you should verify that the number is odd. You will need to:
- create a numerical-type variable
- ask the user for a number (ie print a question on the screen)
- store the entered number in the number-type variable
- check if the number is odd (hint: use the modulus operator, %), if it is not odd, then ask the user again.
Write a program using for loops to produce the following output. |
So when you did the above, you have a numerical-type variable (let's call it user_number for now). You will then need to create a for loop which runs as many times as that user_number:
for (int i=0; i < user_number; i++)
As for the output, you will need to print two things to the screen: spaces and asterisks (*). You will start with a certain amount of spaces on each side of the asterisk, then, as the for-loop repeats, you will need to change the amount of spaces and asterisks until you have the desired shape.
That should get you started. Please do come back to us with any attempted code you have written if you need any further help.
All the best,
NwN