In: Computer Science
Write a C++ program that will output the multiplication table as show below:
1*1=1 2*1=2 3*1=3 …… 9*1=1
1+2=2 2*2=4 3*2=6 …… 9*2=18
……. ……. ……. …… …….
1*9=9 2*8=18 3*9=27 …… 9*9=81
C++ code:
#include <iostream>
using namespace std;
int main(){
//looping from 1 to 9
for(int i=1;i<=9;i++){
//looping from 1 to 9
for(int j=1;j<=9;j++)
//printing the current term in multiplication table
cout<<j<<"*"<<i<<"="<<j*i<<"\t";
//ending the line
cout<<endl;
}
return 0;
}
Screenshot:
Output: