C program to perform addition, subtraction, multiplication, and division
belongs to collection: C programs - Basic C Programs
All Answers
total answers (1)
Severity: 8192
Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated
Filename: libraries/Filtered_db.php
Line Number: 23
belongs to collection: C programs - Basic C Programs
total answers (1)
C program to perform addition, subtraction, multiplication, and division - Source code
Program Output
Program Explanation
1. num1, num2, add, sub and mul variables are declared to store integer values. div variable is declared to store float values as division of two integer numbers can be a float number.
2. Addition, subtraction, multiplication and division is calculated of the two numbers using simple mathematical formulas.
3. While calculation the division, the denominator is type casted to float in order to obtain the result in float.
4. While printing the value of division result on the console %.2f is used, to restrict the result up to two decimal points.
need an explanation for this answer? contact us directly to get an explanation for this answer