Adsense 728 * 15

Search

Custom Search

Print Multiplication Table of a Number - C, C++ Program


Write a C, C++ Program to print multiplication table of a entered number. In this program, a number is input and our program will print multiplication table of that number.

C, C++ Interview Questions

Program to count number of vowels in a string

Print Multiplication Table of a Number in C


 #include <stdio.h>

 int main() {
 
    int num,i;
 
   /* Taking input number */

   printf("Enter number to print table \n");
   scanf("%d",&num);

   /* Run a loop from 1 to 10 */
 
   for(i=1; i <= 10; i++){
  
     printf("%d * %d = %d \n",num,i,i*num);
  
   }
 

 return 0;
}



Output:

Enter number to print table  5

5 * 1 = 5 
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 


C++ Code to Print Multiplication Table of a Number


#include <iostream>
using namespace std;

int main() {
 
   int num,i;
 
   /* Taking input number */

   cout<< "Enter number to print table \n";
   cin >> num;

   /* Run a loop from 1 to 10 */
 
   for(i=1; i<=10; i++){
  
     cout << num << "*" << i << " = " << i*num<<"\n";
  
   }
 
   return 0;
}



Programming question on strings

Sorting algorithms and their time complexity

No comments:

Post a Comment