Multiplication of Two Numbers in C

0
C

In this example, two integers are taken as an input from the user and are multiplicated with each other. The result is then displayed to the user.

#include <stdio.h>

int main() 
{
    int num1, num2, mult;
    
    printf("Please enter the number 1: ");
    scanf("%d", &num1); // Value of number one is stored in num1
    
    printf("Please enter the number 2: ");
    scanf("%d", &num2); // Value of number two is stored in num2
    
    mult = num1 * num2; // Multiplication of two numbers
    
    printf("Multiplication: %d", mult);
    return 0;
}

First of all, the stdio.h library will be included in the program which is resposible for taking input and displaying results. Then two numbers will be taken from the user and will be stored in num1 and num2 variables respectively by using scanf.

    int num1, num2, mult;
    
    printf("Please enter the number 1: ");
    scanf("%d", &num1); // Value of number one is stored in num1
    
    printf("Please enter the number 2: ");
    scanf("%d", &num2); // Value of number two is stored in num2

The mult variable will be used to store the result of multiplication of two variables num1 and num2 in it. Finally, the result stored in mult will be displayed by using the printf statement.

    mult = num1 * num2; // Multiplication of two numbers
    printf("Multiplication: %d", mult);

Output

Please enter the number 1: 4
Please enter the number 2: 8
Multiplication: 32

LEAVE A REPLY

Please enter your comment!
Please enter your name here