# C Program to Print Table of Number

« Previous Program Next Program »

In this tutorial, you will learn and get code about printing the table in following ways:

• Print Table of a given Number
• Print Table from 1 to 10
• Print Table of all numbers in Given Range

## C Print Table of a Given Number

To print the table of any number in C programming, you have to ask from user to enter any number. Then multiply the number with 1 to 10 and display the multiplication result at the time of multiplying the number with 1, 2, 3, ...., 9, 10 as shown here in the program given below.

The question is, write a program in C to receive any number from user (at run-time) and print its table. Here is the answer of this question:

```#include<stdio.h>
#include<conio.h>
int main()
{
int num, i, tab;
printf("Enter the number: ");
scanf("%d", &num);
printf("\nTable of %d is:\n", num);
for(i=1; i<=10; i++)
{
tab = num*i;
printf("%d * %2d = %2d\n", num, i, tab);
}
getch();
return 0;
}```

As the program was written under Code::Blocks IDE, therefore after successful build and run, you will get the following output:

Supply any number say 5 and press ENTER key to see the table of 5 as given in the second snapshot of the sample run:

#### Program Explained

• Receive any number as input say 5 to print the table of 5
• Create a for loop that starts with 1 to 10
• Inside the for loop, multiply the number with the value of i and initialize it to another variable say tab
• Then print the value of tab as output each and every time after multiplication and initialization inside the for loop
• Here at first time, i holds 1 and then tab will hold num*i or 5*1 or 5
• At second time, i holds 2 and then tab will hold num*i or 5*2 or 10
• In this way tab will hold, 5, 10, 15, ..., 45, 50

## C Print Table from 1 to 10

This program will print table from 1 to 10:

```#include<stdio.h>
#include<conio.h>
int main()
{
int num=1, res, i, j;
printf("\t\tTable from 1 to 10\n\n");
for(i=0; i<10; i++)
{
printf("Table of %d = ", num);
for(j=1; j<=10; j++)
{
res = num*j;
printf("%d  ", res);
}
printf("\n");
num++;
}
getch();
return 0;
}```

Here is its sample run:

## C Print Table in Given Range

Let's create another program that will also print the table of number. But this time, the program will ask to enter the range (starting and ending number). The table of all the numbers that comes in between these two given numbers (including both), will gets printed as output:

```#include<stdio.h>
#include<conio.h>
int main()
{
int n1, n2, i, j;
printf("Enter the value of n1 (starting point): ");
scanf("%d", &n1);
printf("Enter the value of n2 (ending point): ");
scanf("%d", &n2);
for(i=n1; i<=n2; i++)
{
printf("Table of %d:\n", i);
for(j=1; j<=10; j++)
{
printf("%d x %d = %d\n", i, j, i*j);
}
printf("\n");
}
getch();
return 0;
}```

Here is the first snapshot of the sample run:

Now supply any two number say 2 and 3 as starting and ending point and press `ENTER` to see the output. The output will be the table of 2 and 3:

#### Same Program in Other Languages

C Online Test

« Previous Program Next Program »