Using a multidimensional array, create a triangular-shaped array. You will ask the user how many lines they want to see and then create the array, fill it, and then print it. You will fill the array with one 1 in the first row, two 2’s in the second row, etc. This should work for any integer that the user enters. (Just because I am starting on 1 does not mean row 0 was skipped.)   You must: use a loop to create the array shape. You must: use nested for loops to fill the array and to print the values back to the screen. Your program should print as shown below.   Example Output:   How many lines would you like in your triangle? >>>9 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5 6 6 6 6 6 6 7 7 7 7 7 7 7 8 8 8 8 8 8 8 8 9 9 9 9 9 9 9 9 9

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter10: Pointers
Section10.3: Pointer Arithmetic
Problem 4E
icon
Related questions
Question

Program:

Using a multidimensional array, create a triangular-shaped array. You will ask the user how many lines they want to see and then create the array, fill it, and then print it. You will fill the array with one 1 in the first row, two 2’s in the second row, etc. This should work for any integer that the user enters. (Just because I am starting on 1 does not mean row 0 was skipped.)

 

You must: use a loop to create the array shape.

You must: use nested for loops to fill the array and to print the values back to the screen. Your program should print as shown below.

 

Example Output:

 

How many lines would you like in your triangle?

>>>9

1

2 2

3 3 3

4 4 4 4

5 5 5 5 5

6 6 6 6 6 6

7 7 7 7 7 7 7

8 8 8 8 8 8 8 8

9 9 9 9 9 9 9 9 9

 

If your code looks like the code below, it is not what I’m asking for. The code below is making a square multidimensional array, not a triangular one. The code below is just leaving certain spots empty so that it looks like a triangle. I will ask you to redo your code if you do this. Your code should leave the second square brackets empty.

 

int response = scan.nextInt();

int[][] triangle = new int[response][response];

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning