Skip to content

Instantly share code, notes, and snippets.

@byronmejia
Created March 18, 2016 07:54
Show Gist options
  • Save byronmejia/4627d478b7329b984a28 to your computer and use it in GitHub Desktop.
Save byronmejia/4627d478b7329b984a28 to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main() {
double x = 0;
double y = 0;
double z = 0;
char c = ' ';
WHILE:
printf("Enter First Number: ");
scanf("%lf", &x);
printf("Enter Second Number: ");
scanf("%lf", &y);
CHAR:
printf("Enter calc [*,/,+,-]: ");
scanf("%c", &c);
switch(c){
case '*':
z = x * y;
goto ANS;
case '/':
z = x / y;
goto ANS;
case '+':
z = x + y;
goto ANS;
case '-':
z = x - y;
goto ANS;
}
goto CHAR;
ANS: printf("Answer: %lf\n", z);
ANOTHER: printf("Another? [y/n]");
scanf("%c", &c);
switch(c){
case 'y':
case 'Y':
goto WHILE;
case 'n':
case 'N':
goto EXIT;
}
goto ANOTHER;
EXIT: printf("GoodBye");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment