Home / Programs / C program to print the multiplication table of 2 from 1 to 10 using while loop.
Programming Example

C program to print the multiplication table of 2 from 1 to 10 using while loop.

👁 11,458 Views
💻 Practical Program
📘 Step by Step Learning
This program prints a multiplication table of 2 from 1 to 10. We have used while loop to achieve our result. Initially i is assigned to 1. The condition to be tested is i<=10. After executing the loop

Program Code

#include<stdio.h>
int main()
{
    int i=1;
    while(i<=10)
    {
        printf("2 * %d = %d\n",i,2*i);
        i++;
    }
    return 0;
}

Output

2 * 1 = 2
2 * 2 = 4
2 * 3 = 6
2 * 4 = 8
2 * 5 = 10
2 * 6 = 12
2 * 7 = 14
2 * 8 = 16
2 * 9 = 18
2 * 10 = 20
Press any key to continue . . .

Explanation

This program prints a multiplication table of 2 from 1 to 10. We have used while loop to achieve our result. Initially i is assigned to 1. The condition to be tested is i<=10. After executing the loop each time, the value of i is increased by 1. When the value of i becomes 11, the condition becomes false and the loop is terminated.

How to learn from this program

First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.