Question: main.cpp / / CS 1 4 1 Lab 4 : Multiplication Table starter code. / / Complete the code to display all or part of
main.cpp
CS Lab : Multiplication Table starter code.
Complete the code to display all or part of a multiplication table.
#include
#include for setw
using namespace std;
Use a loop to display the numbers
Sample output:
Lab : Using loops
Show single row
Show multiplication table
Show a subset of a multiplication table
Exit the program.
Your choice
Enter the limit for the line of numbers:
Single line:
Done.
void singleLine int limit
cout "Single line:" endl;
Your code goes here
end singleLine
Use a loop within a loop to display a multiplication table
Sample output:
Lab : Using loops
Show single row
Show multiplication table
Show a subset of a multiplication table
Exit the program.
Your choice
Multiplication Table:
Done.
void allRowsAndColumnsint size
cout "Multiplication Table:" endl;
Your code goes here, with a loop for the rows, and inside of that
a loop for the columns within that row.
end allRowsAndColumns
Use a loop within a loop to display a subset from a
multiplication table, showing only some rows and columns.
Sample output:
Lab : Using loops
Show single row
Show multiplication table
Show a subset of a multiplication table
Exit the program.
Your choice
Enter the row start and limit and the col start and limit:
Multiplication Table for rows to and columns to
Done.
void selectRowsAndColumnsint rowStart, int rowLimit, int colStart, int colLimit
cout "Multiplication Table for
"rows rowStart to rowLimit and
"columns colStart to colLimit
endl;
Your code goes here
end selectRowsAndColumns
Display menu options and jump to the corresponding code.
int main
Declare variables to use in displaying all or part of a table.
These variables don't all get used in all the cases below.
int rowStart, rowLimit, colStart, colLimit, size;
Initialize them all to
rowStartrowLimitcolStartcolLimitsize;
Used to handle the menu option
char menuChoice ;
whilemenuChoice
cout
"Lab : Using loops
Show single row
Show multiplication table
Show a subset of a multiplication table
Exit the program.
"Your choice ;
cin menuChoice;
cout endl;
Handle menu choice to exit the program
if menuChoice
cout "Exiting"
endl;
else if menuChoice
Show a single line up to some limit
cout "Enter the limit for the line of numbers: ;
cin colLimit;
singleLine colLimit;
else if menuChoice
cout "Enter the size for the multiplication table: ;
cin size;
Show all rows and columns in the multiplication table
allRowsAndColumnssize;
else if menuChoice
Show just the selected subset of the multiplication table
cout "Enter the row start and limit and the col start and limit: ;
cin rowStart rowLimit colStart colLimit;
selectRowsAndColumns rowStart, rowLimit, colStart, colLimit;
cout "Done." endl;
return ;
end main
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
