Program

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Saba
    New Member
    • Oct 2006
    • 16

    Program

    a) Use for loops to construct a program that displays a pyramid of numbers on the screen.
    The pyramid should look like this:

    1
    2 2
    3 3 3
    4 4 4 4
    5 5 5 5 5

    Ask the user to enter a digit (0-9) and display the pyramid with limit up to that number (as shown above).
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    Do you know how to use a for loop?

    Do you know how to use printf?

    If the answer to both these questions is yes then write the code yourself and post any problems you have along with the code.

    If the answer to either question is no then go and look up for loops and printf in you text books, then write the code yourself and post any problems you have along with the code.

    Comment

    • Saba
      New Member
      • Oct 2006
      • 16

      #3
      Plz help mee.......

      a) Use for loops to construct a program that displays a pyramid of numbers on the screen.
      The pyramid should look like this:

      1
      2 2
      3 3 3
      4 4 4 4
      5 5 5 5 5

      Ask the user to enter a digit (0-9) and display the pyramid with limit up to that number (as shown above).


      Hints
      You may nest two inner loops, one to print spaces and one to print numbers (0-9), inside an outer loop that steps down the screen from line to line.

      do all coding using "cout "

      Comment

      • Banfa
        Recognized Expert Expert
        • Feb 2006
        • 9067

        #4
        Please don't double post.

        Comment

        • Saba
          New Member
          • Oct 2006
          • 16

          #5
          please guide me.....

          Comment

          • arne
            Recognized Expert Contributor
            • Oct 2006
            • 315

            #6
            Originally posted by Saba
            please guide me.....
            This IS exactly what Banfa tried to do ...

            Comment

            Working...