Last active
November 23, 2022 15:09
-
-
Save jakariyaa/fc48b411f79374327eef7c70a5f9b2b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<stdio.h> | |
int main() | |
{ | |
double num1, num2, value; | |
char sign; | |
printf("Please enter a basic math expression following two numbers: "); | |
scanf("%lf %c %lf", &num1, &sign, &num2); | |
if (sign == '+') | |
value = num1 + num2; | |
else if (sign == '-') | |
value = num1 - num2; | |
else if (sign == '*') | |
value = num1 * num2; | |
else if (sign == '/') | |
value = num1 / num2; | |
else | |
{ | |
printf("\n Input is INVALID! \n Error : %d \n Try : 25 + 25 \n", 420); | |
return 0; | |
} | |
printf("%lf %c %lf = %lf\n", num1, sign, num2, value); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment