C++ Write a program that asks for a number and then prints as many lines as the
ID: 3915013 • Letter: C
Question
C++ Write a program that asks for a number and then prints as many lines as the user inputs. Each line contains as many pairs of characters ("*#") as the number of this line. It should look like the right half of a pyramid. Your version of the program must print the same result as the expected output. To to this lab, you must use two do-while loops. Two exceptions: When the user inputs a number less than 1, then the program writes only one line. When the user inputs a number greater than 20, then the program writes only twenty lines.#include <stdio.h>
int main() {
/* your code */ return 0;
} Example input Example output *tt * # * # * # * #
Explanation / Answer
#include int main() { int n, i, j; scanf("%d", &n); if(n < 1) { n = 1; } else if(n > 20) { n = 20; } i = 0; do { j = 0; do { printf("*#"); j++; } while(jRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.