Thread: Newbie help

  1. #1
    qwert
    Guest

    Newbie help

    Hello. I was given the task to create a dimond. For example, if the user imputs 5, the output would be:

    $
    $$$
    $$$$$
    $$$
    $

    get it? While it was easy to get this part:

    $
    $$$
    $$$$$

    I have having problems with the bottom part. I am only allowed to use 2 loops(1 nested loop). Any ideas?

    Please be gentle, I am a newbie.

  2. #2
    Green Member Cshot's Avatar
    Join Date
    Jun 2002
    Posts
    892
    Use a for loop and increment your index forward. Then use another that indexes it backwards.
    Try not.
    Do or do not.
    There is no try.

    - Master Yoda

  3. #3
    qwert
    Guest
    I'm not sure I follow. Here is what I have.

    <code> for ( int i = 3; i<=dn; i+=2)
    {
    for (int j=1; j<=i; j++)
    {
    cout<<dc;

    }


    cout<<endl;
    }</code>

    No somewhere in those loops I must make it print backwards. I figure I gotta set up an if clause once it reaches the max number, but I don't know what to do with it.

  4. #4
    Registered User
    Join Date
    Jan 2002
    Posts
    559
    Read Cshot's answer again. You need a second for loop, initialize it to 5, then decrement it instead of increment. You don't need to nest these loops.
    Also, nice try on the code tags, at least you tried, but they should be straight brackets
    Code:
     ...
    , not angle brackets. Or use the php button.
    Last edited by salvelinus; 10-08-2002 at 05:10 PM.
    Truth is a malleable commodity - Dick Cheney

  5. #5
    Registered User
    Join Date
    Jun 2002
    Posts
    106
    you can use output flags to do that read about the flags becouse i saw this kind of example in a book in output flags section
    C++ Makes you Feel Better

    "Gravity connot be held reponsible for people falling in love"--Albert Einstein

  6. #6
    qwert
    Guest
    Originally posted by salvelinus
    Read Cshot's answer again. You need a second for loop, initialize it to 5, then decrement it instead of increment. You don't need to nest these loops.
    Also, nice try on the code tags, at least you tried, but they should be straight brackets
    Code:
     ...
    , not angle brackets. Or use the php button.
    Sorry about the brackets. Anyway, I NEED to use nested loops. It is part of the project.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getting to grips with allegro and ms vc++ (newbie)
    By jimjamjahaa in forum C++ Programming
    Replies: 4
    Last Post: 11-18-2005, 07:49 PM
  2. Newbie in problem with looping
    By nrain in forum C Programming
    Replies: 6
    Last Post: 11-05-2005, 12:53 PM
  3. Newbie Programmer
    By Extropian in forum C++ Programming
    Replies: 3
    Last Post: 05-18-2004, 01:17 PM
  4. Some help for a newbie?
    By Ilmater in forum C++ Programming
    Replies: 23
    Last Post: 04-19-2004, 07:44 PM
  5. Newbie Game Develpoers Unite!
    By Telenosis in forum Game Programming
    Replies: 10
    Last Post: 06-22-2002, 02:02 PM