By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,615 Members | 1,961 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,615 IT Pros & Developers. It's quick & easy.

I need help

P: 1
First off, I need to mention this: I am in a basic programing (c++) class. So please refraim from using methoods above basic functions. I am a student who has no idea on how to solve this problem:

1. Write a program that asks the user to enter an odd integer between
1 and 10 (both inclusive). If the integer value was 3, then print out the following pattern on screen.
*
***
*
If the value was 5, then the pattern printed is as follows:
*
***
*****
***
*

*Note: the stars are in a diamond shape... website wont let me do spacing...

And so on for other odd values less than 10.
Use nested control statements in your program to get the desired output.

If it wasn't for the last sentence, i'd do a bunch of if then statements, but that methood isn't allowed... any idea? i been at this for the past 12 hours now...
Apr 23 '06 #1
Share this Question
Share on Google+
1 Reply


Banfa
Expert Mod 5K+
P: 8,916
Use nested control statements in your program to get the desired output.

If it wasn't for the last sentence, i'd do a bunch of if then statements, but that methood isn't allowed... any idea? i been at this for the past 12 hours now...
Would it help you if I were to tell you that an if statement is a control statement, it controls the flow of the program. The nesting just means that the if statement should contain further if statements.

Post an attempt and solving the problem if you want further help.

*Note: the stars are in a diamond shape... website wont let me do spacing...
Yes you can, like this

Expand|Select|Wrap|Line Numbers
  1.        *
  2.       ***
  3.        *
  4.  
  5.        *
  6.       ***
  7.      *****
  8.       ***
  9.        *
  10.  
Apr 24 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.