176k views
3 votes
Write a program that generates multiplication tables for the user. The program will ask the user for a number and generate a multiplication table for that number. Do NOT use functions or arrays on this. (You need nested for loops for this!)

The program should start by displaying a menu similar to this:

MENU

a) Generate Multiplication Table

q) Quit Program

Please make a selection:

1 Answer

4 votes

Answer:

#include <iostream>

using namespace std;

int main() {

int n;

cout<<"Enter any number between 1 to 10000 to generate their Multiplication table"<<endl;//menu

cin>>n;//taking input..

for(int i=1;i<=10;i++)//looping from 1 to 10.

{

cout<<n<<" x "<<i<<" = "<<n*i<<endl;//printing the table..

}

return 0;

}

Output:

Enter any number between 1 to 1000 to generate their Multiplication table

545

545 x 1 = 545

545 x 2 = 1090

545 x 3 = 1635

545 x 4 = 2180

545 x 5 = 2725

545 x 6 = 3270

545 x 7 = 3815

545 x 8 = 4360

545 x 9 = 4905

545 x 10 = 5450

Step-by-step explanation:

I have taken an integer n for taking input.Then i have looped from 1 to 10 and generating the table and printing it not storing it in the array.Just using loop.

User Yamile
by
6.4k points