C Multiplication Operator

In C Programming, Multiplication Operator is used to find the product of two numbers. The operator takes two operands and returns the product of these two operands.

In this tutorial, we shall learn about Arithmetic Multiplication Operator and its usage with examples.

Operator Symbol

The symbol of Arithmetic Multiplication Operator is *.

ADVERTISEMENT

Syntax

The syntax of Multiplication Operator with two operands is

operand1 * operand2

When this operator is given with operands of different numeric datatypes, the lower datatype is promoted to higher datatype.

Examples

In the following program, we take two integers in a, b, and find their product using Multiplication Operator.

main.c

#include <stdio.h>

int main() {
    int a = 12;
    int b = 7;
    
    int result = a * b;
    printf("Result : %d\n", result);
    
    return 0;
}

Output

Result : 84
Program ended with exit code: 0

In the following program, we take two float values in a, b, and find their product using Multiplication Operator.

main.c

#include <stdio.h>

int main() {
    float a = 1.2;
    float b = 0.3;
    
    float result = a * b;
    printf("Result : %f\n", result);
    
    return 0;
}

Output

Result : 0.360000
Program ended with exit code: 0

In the following program, we take two numeric values of different datatypes, say an integer value in a, and a floating point value in b, and find their product.

main.c

#include <stdio.h>

int main() {
    int a = 2;
    float b = 0.3;
    
    float result = a * b;
    printf("Result : %f\n", result);
    
    return 0;
}

Output

Result : 0.600000
Program ended with exit code: 0

Since, int is the lower datatype and float is the higher datatype, the operation a * b promotes a to float datatype.

Conclusion

In this C Tutorial, we learned how to use Arithmetic Multiplication Operator to find the product of numeric values with examples.