Header Ads Widget

Responsive Advertisement

Calculator With C

#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("Addition = %d\n",add);
   printf("Subtract = %d\n",subtract);
   printf("Multiplication = %d\n",multiply);
   printf("Division = %.2f\n",divide);
 
   return 0;
}

-------------------------------
@@@@ OUTPUT @@@@

Enter two integers
2
2
Addition = 4
Subtract = 0
Multiplication = 4
Division = 1.00

Post a Comment

0 Comments