SIMPLE CALCULATOR
Code :
#include<stdio.h>
int main()
{
float cal,ch, num1, num2;
printf("==========================================\n");
printf("\t SIMPLE CALCULATOR\n");
printf("==========================================\n");
printf("Enter two numbers: ");
scanf("%f %f", &num1, &num2);
printf("\n");
printf("---------------------------\n");
printf("\t MENU\n");
printf("---------------------------\n");
printf("1. Addition\n");
printf("2. Subtraction\n");
printf("3. Multiplication\n");
printf("4. Division\n");
printf("---------------------------\n\n");
printf("Instructions :\nTo make any calculation of above\n just simply enter its serial number.\n\n");
printf("Choice : ");
scanf("%f", &ch);
printf("\n");
if(ch == 1)
{
cal = num1 + num2;
printf("Addition = %.2f\n", cal);
}
else if(ch == 2)
{
cal = num1 - num2;
printf("Subtraction = %.2f\n", cal);
}
else if(ch == 3)
{
cal = num1 * num2;
printf("Multiplication = %.2f\n", cal);
}
else if(ch == 4)
{
cal = num1 / num2;
printf("Division = %.2f\n", cal);
}
else
{
printf("Error !! Invalid Choice.\n");
}
printf("-----------------------------------------\n");
return 0;
}
Come again Learn again !
« iCodeBuzz »
No comments:
Post a Comment