Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

use nested 'do while', 'while' and 'for' loop to answer it

nested do while whilw for

This topic has been archived. This means that you cannot reply to this topic.
4 replies to this topic

#1 NadeeyaMustakim


    CC Lurker

  • Just Joined
  • Pip
  • 1 posts

Posted 10 November 2014 - 04:54 PM

how to make the output be like this? the user will entered number between 1-20. if user entered 5 thus the output will be like :












#2 Alexander



  • Moderator
  • 3963 posts

Posted 10 November 2014 - 06:45 PM

What do you have so far? If you notice, if the user enters 5, then it will grow to five in length and then descent in length, so you must have a loop that increases the length until it is what the user had entered and then decrease the length until it is 1 again. You can figure out how to nest these loops in a certain order to make this happen.



All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.

#3 Sundance


    CC Devotee

  • Validating
  • PipPipPipPipPipPip
  • 572 posts

Posted 10 November 2014 - 07:05 PM

Also to follow on from Alexanders tips...think of using the less than symbol < and using an incretement.

Please read the

FaQ & Guidelines

#4 BlackRabbit


    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 10 November 2014 - 09:44 PM

Welcome aboard,


Which programing language? You could do it in one loop only too, but it would be a little more complicated.


Anyway, declare which programing language you are using, ask for this post to be moved  to that language's forum, and post what code you do actually have. :)

#5 WingedPanther73


    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 11 November 2014 - 05:48 AM

Two nested for loops.

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download