Question

In: Computer Science

"Create a program that displays a table consisting of four rows and five columns. The first...

"Create a program that displays a table consisting of four rows and five columns. The first column should display the numbers 1 through 4. The second and sub-sequent columns should display the result of multiplying the number in the first column by the numbers 2 through 5. If necessary, create a new project named Introductory14 Project, and save it in the Cpp8\Chap08 folder. Enter the C++ instructions into a source file named Introductory14.cpp. Also enter appropriate comments and any additional instructions required by the compiler. Save and then run the program."

I need help with making this C++ code. it needs to be done using a POST-TEST loop and i am not sure how to use "do" and "while"

Solutions

Expert Solution

code in c++ (code to copy)

#include<bits/stdc++.h>
using namespace std;
int main()
{
        // create  a table consisting of four rows and five columns
        int table[4][5];
        // The first column should display the numbers 1 through 4
        int i=0;
        while(i<4){
                table[i++][0]=i;
        }
        // The second and sub-sequent columns should display 
        // the result of multiplying the number in the first
        // column by the numbers 2 through 5
        int col=1;
        // using a post test loop
        while(1){
                //break from loop of column value is 5
                if(col==5){
                        break;
                }
                int row=0;
                // using a post test loop
                while(1){
                        //break from loop of row value is 4
                        if(row==4){
                                break;
                        }
                        // result of multiplying the number in the first column by the numbers 2 through 5
                        table[row][col]=table[row][0]*(col+1);
                        row++;
                }
                col++;
        }
        //print the table
        for(int i=0;i<4;i++){
                for(int j=0;j<5;j++){
                        cout<<table[i][j]<<" ";
                }
                cout<<endl;
        }
}

Code screenshot

Sample console output screenshot


Related Solutions

1 – Create a webpage that contains a table with exactly three rows and two columns....
1 – Create a webpage that contains a table with exactly three rows and two columns. The first row will contain a table heading containing the name of a US National Park, that spans across all columns. Hint: use the colspan attribute inside the opening th tag Give the table heading an onmouseover that will change the text of the heading when it is moused over to read My Favorites Park! (Hint: use innerHTML). Use onmouseout to change it back....
Write a Python program which adds up columns and rows of given table as shown in...
Write a Python program which adds up columns and rows of given table as shown in the specified figure. Example test case (the four lines below “Input cell value” are input from user, and the five lines below “Results:” are the output of the program.): Input number of rows/columns (0 to exit) 4 Input cell value: 25 69 51 26 68 35 29 54 54 57 45 63 61 68 47 59 Result:             25   69   51   26 171...
Write a Python program which adds up columns and rows of given table as shown in...
Write a Python program which adds up columns and rows of given table as shown in the specified figure. Example test case (the four lines below “Input cell value” are input from user, and the five lines below “Results:” are the output of the program.): Input number of rows/columns (0 to exit) 4 Input cell value: 25 69 51 26 68 35 29 54 54 57 45 63 61 68 47 59 Result: 25 69 51 26 171 68 35...
/*Question 3: The following data contains five columns (variables) and five rows (observations). First, read the...
/*Question 3: The following data contains five columns (variables) and five rows (observations). First, read the data into SAS to create a data set. Notice that the first, third, and the fifth variable have missing values. Please replace the missing values of the first, third, and fifth variable with 30, 40, and 50, respectively. Next, for all the variables, if a value is at least 100, make an adjustment to the value such that its new value is equal to...
Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.
Assignment 3 – Incorporating a Table into a Document.Create a Word document and title it “College Expenses”. In the Word document, insert a table with at least 5 rows and 5 columns. Insert>Table.Tell me about your college expenses you have by filling this table with subjects and data. Then write two paragraphs telling me about the information you provided in the table. Bold and color table heading.  Example of table:College ExpensesTuitionBooksComputer/InternetOther suppliesScience ClassMath classC.I.S. ClassEnglish ClassGive the page a proper title....
Create new Deck object Run testDeck( ) Should get four columns (13 rows each), each column...
Create new Deck object Run testDeck( ) Should get four columns (13 rows each), each column with a unique suit and ranked ace to king Run shuffle( ) then run testDeck( ) again Should get four NEAT columns,(13 rows each) with random numbers and suits in each column Create another Deck object Run testDeal( ) with a parameter of 5 Should get Ace, 2, 3, 4, 5 of spades as the “hand” Now run shuffle( ) then run testDeal( )...
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John...
Create a table with two columns. Name the table First Initial _ Last Name (e.g. John Dow will create table j_dow). You have to audit all DML statements on your table. To do this you write two triggers: 1. To log any DML statements that users might run on this table. The results must be stored in the First Initial _ Last Name _ Log table (e.g. John Dow will create table j_dow_log). The table should have unique event ID,...
When testing for independence in a contingency table with 2 rows and 2 columns at 5%...
When testing for independence in a contingency table with 2 rows and 2 columns at 5% level of significance, the critical value of the test statistic is____
Create the table users with four columns: user_id, email_address, first_name, and last_name. Make user_id as the...
Create the table users with four columns: user_id, email_address, first_name, and last_name. Make user_id as the primary key. For each column, use the data type specified in the schema.
For the next four questions, consider the following table of a city consisting of five districts...
For the next four questions, consider the following table of a city consisting of five districts that is debating where to build a new stadium and a free public wifi network. The table shows the benefit (positive) or harm (negative) in each city district from doing these projects. The socially best outcome (highest total benefit to the whole city) is to Question 11 options: build the stadium but not the wifi network. build the wifi network but not the stadium....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT