C Program To Generate Multiplication Table

In this post, you will learn how to generate a multiplication table using C Programming language.

C Program To Generate Multiplication Table

A multiplication table is a table which shows the product of two numbers.

This program will generate a multiplication table of an integer entered by the user.

So, without further ado, let’s begin the tutorial.

Contents

C Program To Generate Multiplication Table

// C Program To Make a Multiplication Table
#include <stdio.h>
int main(){
    int n, i;
    
    // Asking for Input 
    printf("Enter the Number: ");
    scanf("%d", &n);
    
    // logic
    for (i = 1; i <= 10; ++i){
        printf("%d * %d = %d\n", n, i, n*i);
    }
    return 0;
}

Output

Enter the Number: 15
15 * 1 = 15
15 * 2 = 30
15 * 3 = 45
15 * 4 = 60
15 * 5 = 75
15 * 6 = 90
15 * 7 = 105
15 * 8 = 120
15 * 9 = 135
15 * 10 = 150

How Does This Program Work ?

    int n, i;

In this program, we have declared two int type variables named n and i.

    // Asking for Input 
    printf("Enter the Number: ");
    scanf("%d", &n);

Then, the user is asked to enter the value of the integer. This value will be stored in n variable.

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

Now, the logic part of the program starts. We have used for loop statement to generate the multiplication table of the integer.

Some of the used terms are as follow:

#include <stdio.h> – In the first line we have used #include, it is a preprocessor command that tells the compiler to include the contents of the stdio.h(standard input and output) file in the program. 

The stdio.h is a file which contains input and output functions like scanf() and printf() to take input and display output respectively. 

Int main() – Here main() is the function name and int is the return type of this function. The Execution of any Programming written in C language begins with main() function.

scanf() – scanf() function is used to take input from the user.  

printf() – printf() function is used to display and print the string under the quotation to the screen. 

for loop – A loop is used for initializing a block of statements repeatedly until a given condition returns false.

\n – It moves the cursor to the starting of the next line.

ValueImpression Mobile Ads === codingbroz.com_300x250 (#88863) ===
=== codingbroz.com_300x250 (#88863) ===

// – Used for Commenting in C. 

Conclusion

I hope after reading this post, you learned how to generate a multiplication table using C Programming language.

If you have any doubts regarding the topic, feel free to contact us in the Comment Section. We will be delighted to help you.

Leave a Comment

Your email address will not be published.