C Program to Find & Display Multiplication table

«
»

This is a C Program to Find & Display Multiplication table.

Problem Description

This program finds & displays the multiplication table of a particular number.

Problem Solution

1. Take a number as input.
2. Using while loop print the number and its product with numbers 1-10 as output.

advertisement
Program/Source Code

Here is source code of the C Program to Find & Display Multiplication table. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

  1. /*
  2.  * C Program to Find & Display Multiplication table
  3.  */
  4. #include <stdio.h>
  5.  
  6. int main()
  7. {
  8.     int number, i = 1;
  9.  
  10.     printf(" Enter the Number:");
  11.     scanf("%d", &number);
  12.     printf("Multiplication table of %d:\n ", number);
  13.     printf("--------------------------\n");
  14.     while (i <= 10)
  15.     {
  16.         printf(" %d x %d = %d \n ", number, i, number * i);
  17.         i++;
  18.     }
  19.     return 0;
  20. }
Program Explanation

1. Take a number as input and store it in the variable number.
2. Using while loop starting from 1 to 10, print the variable number, i and (number * i) as output and exit.

advertisement
Runtime Test Cases
Output:
 
Enter the Number:6
Multiplication table of 6:
--------------------------
 6 x 1 = 6
 6 x 2 = 12
 6 x 3 = 18
 6 x 4 = 24
 6 x 5 = 30
 6 x 6 = 36
 6 x 7 = 42
 6 x 8 = 48
 6 x 9 = 54
 6 x 10 = 60

Sanfoundry Global Education & Learning Series – 1000 C Programs.

Here’s the list of Best Reference Books in C Programming, Data-Structures and Algorithms

If you wish to look at other example programs on Mathematical Functions, go to C Programming Examples on Mathematical Functions. If you wish to look at programming examples on all topics, go to C Programming Examples.

advertisement
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn