2 Write a c function that takes as input an integer It then

2. Write a c++ function that takes as input an integer. It then prints out the multiplication tables between 1 and 12

and that integer using a for loop.(Note that this must use a for loop!)

Solution

#include <iostream>
using namespace std;

void multiplicationTable(int number) //function to display multiplication table of number
{
   for(int i=1;i<=12;i++)
   {
       cout<<\"\ \"<<number<<\" * \"<<i<<\" = \"<<i*number;
   }
}
int main()
{
   int num;
   cout<<\"Enter the number to print its multiplication table\";
   cin>>num;
  
   multiplicationTable(num); //function call
  
  
   return 0;
}

output:

2. Write a c++ function that takes as input an integer. It then prints out the multiplication tables between 1 and 12 and that integer using a for loop.(Note th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site