2.write a C program to perform addition, subtraction, multiplication and division.
#include <stdio.h>
#include <stdlib.h>
int main()
{
int a,b, add, subtract, multiple;
float divide;
printf("Enter two values:\n");
scanf("%d%d", &a, &b);
add = a+b;
subtract = a - b;
multiple = a*b;
divide = a/ (float)b;
printf("Sum = %d\n", add);
printf("Difference = %d\n", subtract);
printf("Multiplication = %d\n", multiple);
printf("Division = %.2f\n", divide);
return 0;
}
Result:
No comments:
Post a Comment