Generate Multiplication Table using for loop in C  

for loop is used to execute a block of statements repeatedly. It is commonly used when number of iterations known. It has 3 expressions: Initialization,Condition and Inc/Dec each separated by semicolon.

0 374 Technology | C-Programming
Tue Dec 25 , 2018

Syntax

for (Initialization;Condition;Increment/Decrement)
{
  // statements to be executed
}

Example

Program to print or generate Multiplication Table of a number (entered by the user) using for loop.


#include <stdio.h>
int main()
{
    int num, i;

    printf("Enter a number: ");
    scanf("%d",&num);

    printf("Table of %d is:\n",num);

    for(i=1; i<=10; i++)
    {
        printf("%d * %d = %d \n\n", num, i, num*i);
    }
    
    return 0;
}


Output

Enter a number: 5
Table of 5 is:
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 


Subscribe & Get Regular Updates On Your E-mail