asked 141k views
3 votes
In C++, write a program that asks the user to input an integer and then calls a function named

multiplicationTable(), which displays the results of multiplying the integer by each
of the numbers 2 through 10.

1 Answer

3 votes

Answer:

//Program in C++.

// header

#include <bits/stdc++.h>

using namespace std;

// function to multiply number with 2-10

void multiplicationTable(int num)

{

cout<<"Number when multiplied with 2-10:"<<endl;

for(int a=2;a<=10;a++)

{

// multiply number with 2-10

cout << num << " * " << a << " = " << num*a << endl;

}

}

// driver function

int main()

{

// variable

int num;

cout<<"Enter a number:";

// read number from user

cin>>num;

// call the function

multiplicationTable(num);

return 0;

}

Step-by-step explanation:

Read a number from user and assign it to variable "num".Call the function multiplicationTable() with parameter "num".In this function, multiply number with each from 2 to 10 and print the value.

Output:

Enter a number:5

Number when multiplied with 2-10:

5 * 2 = 10

5 * 3 = 15

5 * 4 = 20

5 * 5 = 25

5 * 6 = 30

5 * 7 = 35

5 * 8 = 40

5 * 9 = 45

5 * 10 = 50

answered
User Drew Hall
by
8.2k points