- To print the multiplication table of a number
User Input : 3
Output:
3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 X 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30
#include <iostream>
using namespace std;
int main() {
int num;
cout<<"Enter your number: ";
cin>>num;
cout<<"Multiplication table of "<<num<<endl;
for(int i=1; i<=10; i++)
cout<<num<<" X "<<i<<" = "<<num*i<<endl;
return 0;
}
Enter your number : 5 Multiplication table of 5 5 x 1 = 5 5 x 2 = 10 5 x 3 = 15 5 x 4 = 20 5 x 5 = 25 5 x 6 = 30 5 X 7 = 35 5 x 8 = 40 5 x 9 = 45 5 x 10 = 50Program
Here we just multiply the number by 1 to 10 and print it on the output screen
for(int i=1; i<=10; i++)
cout<<num<<" X "<<i<<" = "<<num*i<<endl;
If you want more than 10 multiplication values, just increase the value from 10 inside for loop
Concept