The operators +
, -
and *
computes addition, subtraction, and multiplication respectively as you might have expected.
In normal calculation, 9/4 = 2.25
. However, the output is 2
in the program.
It is because both the variables a and b are integers. Hence, the output is also an integer. The compiler neglects the term after the decimal point and shows answer 2
instead of 2.25
.
The modulo operator %
computes the remainder. When a=9
is divided by b=4
, the remainder is 1
. The %
operator can only be used with integers.
Suppose a = 5.0
, b = 2.0
, c = 5
and d = 2
. Then in C programming,
हिंदी