C Program to Multiply Two Numbers

Howdy readers, today we will learn how to write a program to multiply two numbers using C Programming language.

C Program to Multiply Two Numbers

We are going to write a program that asks the user to enter two numbers. Then, this program computes the product of those two numbers using the (*) arithmetic operator.

So, without any delay, let’s begin this tutorial.

C Program to Multiply Two Numbers

C Program

// C Program to Multiply Two Numbers
#include <stdio.h>
int main(){
    int num1, num2, product;
    
    // Asking for input
    printf("Enter the first number: ");
    scanf("%d", &num1);
    printf("Enter the second number: ");
    scanf("%d", &num2);
    
    // Multiply two numbers
    product = num1 * num2;
    
    // Displaying result
    printf("Product of %d and %d is: %d", num1, num2, product);
    
    return 0;
}

Output

Enter the first number: 3
Enter the second number: 5
Product of 3 and 5 is: 15
C Program to Multiply Two Numbers

Explanation

    int num1, num2, product;

In the above program, we have declared three int data type variables named num1, num2, and product.

    // Asking for input
    printf("Enter the first number: ");
    scanf("%d", &num1);
    printf("Enter the second number: ");
    scanf("%d", &num2);

This program prompts the user to enter two numbers. These two numbers get stored in the num1 and num2 named variables. Here, input is taken with the help of scanf() function.

    // Multiply two numbers
    product = num1 * num2;

We multiply two numbers with the help of the (*) multiplication operator. The product of these two numbers gets stored in the product named variable.

    // Displaying result
    printf("Product of %d and %d is: %d", num1, num2, product);

In the end, the product of two numbers is displayed on the screen using printf() function.

Conclusion

I hope after reading this post, you understand how to write a program to multiply two numbers using C Programming language.

If you have any queries regarding the tutorial, then let us know in the comment section. We will be glad to solve all of your queries.

Leave a Comment