##### Course Content • 1. C Program to Generate Multiplication Table of a Given Number
Free YouTube Video
• 2. C Program to Find Sum Of First n Natural Numbers in O(1)
Free YouTube Video
• 3. C Program to Find Largest Element in an Array
Free YouTube Video
• 4. C Program to Find Prime Number
Free YouTube Video
• 5. C Program to Convert Decimal Number to Binary Number
Free YouTube Video
• 6. C Program to Reverse a Number
Free YouTube Video
• 7. C Program to Calculate Factorial of a Number
Free YouTube Video
• 8. C Program to Print Star Pattern - 1
Free YouTube Video
• 9. C Program to Reverse a String
Free YouTube Video
• 10. C Program To Print Prime Numbers In A Given Range
Free YouTube Video
• 11. C Program To Print Star Pattern - 2
Free YouTube Video
• 12. C Program To Print Star Pattern - 3
Free YouTube Video
• 13. C Program To Print Star Pattern - 4
Free YouTube Video
• 14. C Program To Print Number Pattern - 1
Free YouTube Video
• 15. C Program To Print Star Pattern - 5
Free YouTube Video
• 16. C Program to Count Number of Digits in an Integer
Free YouTube Video
• 17. C Program to Calculate Power of a Number
Free YouTube Video

### C Program to Generate Multiplication Table of a Given Number

In this tutorial, we will write a program for multiplication of tables of a given number in C language. An example program is shown below

``````#include<stdio.h>

int main(){
int num;
// Take the number as an input from the user
printf("Enter the value of number whose multiplication table is to be printed\n");
scanf("%d", &num);
printf("The multiplication table of %d is\n", num);
for (int i = 0; i < 10; i++)
{
printf("%d X %d = %d\n",num, i+1, (i+1)*num);
}

return 0;
}
``````

Code Snippet 1: Multiplication of Table of a Given Number

#### Explanation

As shown in a code snippet 1,

1. We have declared an integer variable “num” which will be used to store user input
2. The “printf” function is used to print “Enter the value of number whose multiplication table is to be printed” at the run time and “/n” will break the line
3. The “scanf” function is used to get input from user; the “%d” refer to an integer and “num” is the variable in which the user input will be stored
4. The “printf” function is used to print “The multiplication table of %d is”, the value of the variable “num” will be printed at the place of “%d”
5. The “for” loop is used to iterate for the given number of times. The “printf” function inside “for” loop is used to print the multiplication table. Every times “for” loops iterates it work print the given number, value of (i+1), and value of (i+1) will be multiplied by the given number. For example if the user input the number 4 then the output will be like:

4 X 1 = 4

4 X 2 = 8

And so on till the value of “i” reaches the value 10. There is another logic to iterate the for loop without adding the value “1” in the variable “i” which is shown below

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

Code Snippet 2: Another way to print table

As shown in the code snippet 2,

1. In this for loop the value of the variable “i” is set to “1” and the loop condition is set to “i <= 10”; due to which we don’t need to add “1” in the value of the variable “i”

The output of the following program is shown below Figure 1: Program Output

### Comments ayushmaster1234567 Jun 7, 2021
Oh bhai maja aa gaya Harry sir subrata01 Jan 12, 2021
sir can not find the link of hand written notes..

#### Resources

No resource files associated with this project

#### Course Announcements

Any Course related announcements will be posted here