Question
Write a program triangle.cpp using while loops for this problem which reads in the number of rows and prints n rows of digits. 1 12
Write a program triangle.cpp using while loops for this problem which reads in the number of rows and prints n rows of digits. 1 12 123 1234 12345 ... where the ith row is 1234 . . . k where k = i mod 10. If a row has more than 10 digits, the digit after 9 should start again from 0. For instance, if the number of rows is 15, the output should be: 1 12 123 1234 12345 123456 1234567 12345678 123456789 1234567890 12345678901 123456789012 1234567890123 12345678901234 123456789012345 a. Read in the number of rows as an integer. b. Use two while loops one inside the other, i.e. nested, to print the digits in each row. c. Use x%10 to compute x mod 10. You will find this useful when a row has more than 10 digits. d. Run your program on sample input, e.g. 1, 2, 10, and 15.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started