Computer Science, asked by pratishmoses, 10 months ago

Write a program which will ask the user to input a choice ch and the height of the triangle h and print either of the following patterns based on the user’s selection. Ch=1 h=4
output :
1
12
123
1234
Ch=2 h=5 output :
12345
1234
123
12
1

Answer it correctly to be marked brainliest!!!..​

Answers

Answered by akashkumar02042001
0

Answer:

What is your question?

pratishmoses

pratishmoses

5 days ago

Computer Science

Secondary School

+5 pts

Answered

Write a program which will ask the user to input a choice ch and the height of the triangle h and print either of the following patterns based on the user’s selection. Ch=1 h=4

output :

1

12

123

1234

Ch=2 h=5 output :

12345

1234

123

12

1

2

SEE ANSWERS

Log in to add comment

Answers

nageshwar70

nageshwar70 Genius

Answer:

// C++ code to demonstrate printing

// pattern of numbers

#include <iostream>

using namespace std;

// Function to demonstrate printing

// pattern

void numpat(int n)

{

// initializing starting number

int num = 1;

// Outer loop to handle number of rows

// n in this case

for (int i = 0; i < n; i++) {

// Inner loop to handle number of columns

// values changing acc. to outer loop

for (int j = 0; j <= i; j++)

cout << num << " ";

// Incrementing number at each column

num = num + 1;

// Ending line after each row

cout << endl;

}

}

// Driver Function

int main()

{

int n = 5;

numpat(n);

return 0;

}

Similar questions