Question
in c++ using repl.it only

Problem 3 : C++, using repl.it for coding ONLY answer, but sure leave to leave comments every two lines explaining what the c
5. (b) Write a program that produces a triangular grid of numbers as a seating chart (start at 1 in the top and keep increasi
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please let me know if anything is required.

Problem 1:

Copyable code:

#include <iostream>

using namespace std;

int main()
{
cout<<"How many columns?\n"; //taking number of rows input from the user
int cols;
cin>>cols;
  
cout<<"How many rows?\n"; //taking number of columns input from the user
int rows;
cin>>rows;
  
cout<<"\n"; //printing thr new line
int k=1;
for (int i=0;i<rows;i++) //printing the seating chart
{
for(int j=0;j<cols;j++)
{
cout<<k<<" ";
k++;
}
cout<<"\n";
}
  

return 0;
}

Sample output:

How many columns? 3 How many rows? 2 1 2 3 4 5 6

Problem 2:

Copyable code:

#include <iostream>

using namespace std;

int main()
{
  
cout<<"How many rows?\n"; //taking number of columns input from the user
int rows;
cin>>rows;
  
cout<<"\n"; //printing thr new line
int k=1;
for (int i=0;i<rows;i++) //printing the triangular seating chart
{
for(int j=0;j<i+1;j++)
{
cout<<k<<" ";
k++;
}
cout<<"\n";
}
  

return 0;
}

Sample output:

How many rows? 4 1 2 3 4 5 6 7 8 9 10

Add a comment
Know the answer?
Add Answer to:
in c++ using repl.it only Problem 3 : C++, using repl.it for coding ONLY answer, but...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • *Using C++* You will create a program that uses a Critter class to move around a...

    *Using C++* You will create a program that uses a Critter class to move around a Grid, which is also a class. The Critter and the Grid classes will be in separate files. The Critter class will have a data member to count the number of moves made. It will also need data members to hold the current x and y coordinates. It will have a member function that randomly moves it one space in one of 4 directions. You...

  • The answer need to write in C programming. QUESTION 2 Write a program using array to...

    The answer need to write in C programming. QUESTION 2 Write a program using array to generate a multiplication table based on the user's input. For example if user enter 5 as input then a multiply table for 1 to 5 is printed as output as shown in Figure Q2. There are three main steps in this program which are: Print rows (a) (b) Print columns Print multiplication of data inside table (c) Select C:\example1 \bin\Debuglexample 1.exe enter the value...

  • Write a code using loop and flag function in python jupitior notebook: Ask the user for...

    Write a code using loop and flag function in python jupitior notebook: Ask the user for the number of items they bought. Also ask the price of each item they bought and quantity purchased. Display the total amount they owe. Ask the user for a number n. Calculate 1+2+3+….+n. Ask the user for a number n. Calculate 1*2*3*…*n. Ask the user for number of rows (r) and columns (c). Print * for r rows and c columns. Ask the user...

  • Part 3: Arrows Write a python program that prompts the user for a number of columns,...

    Part 3: Arrows Write a python program that prompts the user for a number of columns, and them prints the pattern as seen below. You cannot assume that the user will supply positive numbers - if they misbehave you should re-prompt them until they do give you a positive number. Note that your program only has to run one time, but multiple runnings of the program are shown below: How many columns? 3 * * * * * How many...

  • Please help me in thsi question i have only 30 minutes this is python Question Two....

    Please help me in thsi question i have only 30 minutes this is python Question Two. 25 points. Write the missing function such that when the following code executes: import numpy as np # Assume the user enters a valid integer #Assume the user enters o valid integer rows - intinput("Enter number of rows (1-10 ")) inti nputl Enter number of columns 1-10 : columns matrix np.random.randint(1, 11, rows columns).reshapelrows, columns) print"Matrix Shape:" matrix.shape, "MatrixIn". matrix) result sum _border(matrix) print/"The...

  • RASPBERRY Pi 3 / SENSE HAT! Part I - Create a python program that prompts the...

    RASPBERRY Pi 3 / SENSE HAT! Part I - Create a python program that prompts the user to enter a number between 1 and 5. Then the program will light up a dot at various location depending on the value of the input. This will be using control-flow if-elif-else that we covered in class this week: Control Flow - If and Else. 1 = top left corner 2 = top right corner 3 = bottom left corner 4= bottom right...

  • write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different...

    write in C++ Problem 1: Mobile Service Provider A cell phone service provider has three different subscription packages for its customers. Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute. Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute. Package C: For $69.99 per month unlimited minutes provided. Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased...

  • please write c programming for this code below. Write a program to print a pattern of...

    please write c programming for this code below. Write a program to print a pattern of numbers separated by spaces for the given number of rows. At the time of execution, the program should print the message on the console as: Enter number of rows For example, if the user gives the input as: Enter number of rows : 4 then the program should print the result as: 232 34543 4567654

  • with C++ You will create a program that uses a Critter class to move around a...

    with C++ You will create a program that uses a Critter class to move around a Grid, which is also a class. The Critter and the Grid classes will be in separate files. The Critter class will have a data member to count the number of moves made. It will also need data members to hold the current x and y coordinates. It will have a member function that randomly moves it one space in one of 4 directions. You...

  • 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters...

    5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. Enter 7, 2, bob, 10, and 4 and match the output below. ​ 1 largest = None 2 smallest = None 3 while True: 4...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT