C program to add, subtract ,multiply & devide two numbers
Posted by Spider on 12:17 AM
#include <stdio.h> int main() { int first, second, add, subtract, multiply; float divide; printf("Enter two integers :\n"); scanf("%d%d", &first, &second); add = first + second; subtract = first - second; multiply = first * second; divide = first / (float)second; //typecasting printf("\nSum = %d",add);
printf("\nDifference = %d",subtract);
printf("\nMultiplication = %d",multiply);
printf("\nDivision = %.2f",divide);
return 0; }
/*
Output :
Enter two integers :
10
5
Sum = 15
Difference = 5
Multiplication = 50
Division = 2
*/
Tags
C Basics