Addition Subtraction Multiplication and Division Example
#include <stdio.h>
int main() {
double num1, num2;
printf("Enter the first number: ");
scanf("%lf", &num1);
printf("Enter the second number: ");
scanf("%lf", &num2);
// Addition
printf("%.2lf + %.2lf = %.2lf\n", num1, num2, num1 + num2);
// Subtraction
printf("%.2lf - %.2lf = %.2lf\n", num1, num2, num1 - num2);
// Multiplication
printf("%.2lf * %.2lf = %.2lf\n", num1, num2, num1 * num2);
// Division
if (num2 != 0) {
printf("%.2lf / %.2lf = %.2lf\n", num1, num2, num1 / num2);
} else {
printf("Division by zero is not allowed.\n");
}
return 0;
}
Comments
Post a Comment