Computer Science, asked by aashiseesu123, 1 day ago

Write a program to display the multiplication table of a given number. Assume that the number will be the input to the variable n. The body of the loop is given below: cout<<i<< X"<<n<<"= Give the output also. n <<"\n"; do​

Answers

Answered by samarthkrv
2

Answer:

#include <iostream>

using namespace std;

int main() {

  int n;

  cout << "Enter the number of which you want to print multiplication table:";

  cin >> n;

      for(int i = 1; i <= 10; i++){

          cout<< n <<"x" << i << "=" << (n*i) << "\n";

      }

  return 0;

}

Explanation:

Answered by anindyaadhikari13
3

Solution:

The given problem is solved in C++.

#include <iostream>

using namespace std;

int main() {

   int i, n;

   cout << "Enter an integer number: ";

   cin >> n;

   cout << "\nMultiplication table of " << n << ":\n";

   for(i = 1;i <= 10;i++)

       cout << n << " x " << i << " = " << n * i << endl;

   return 0;

}

Explanation:

  • At first, we ask the user to enter an integer. The integer is then stored in a variable (n).
  • Then we create a loop that iterates 10 times so as to display the multiplication table. Here, i is the looping variable. Its initial value is 1. The loop iterates until i <= 10 is true.
  • Then, the product of i and the the number is displayed on the screen using cout object.
  • In this way, our problem is solved..!!

Refer to the attachment for output.

Attachments:
Similar questions