#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct Stack {
float stack[1024];
int stack_ptr;
};
void initStack(struct Stack *st)
{
st->stack_ptr = 0;
}
void Push(struct Stack *st, float var)
{
if(st->stack_ptr < 1024)
st->stack[st->stack_ptr++] = var;
else
printf("Stack overflow\n");
}

float Pop(struct Stack *st)
{
if(st->stack_ptr >= 0)
return st->stack[--st->stack_ptr];
else
printf("Stack Underflow\n");return 0;
}

struct Stack masc__st;
int masc_loop_func();
int masc_getnum();
int masc_printselection();
int masc_printresult();
int masc_addition();
int masc_subtraction();
int masc_multiplication();
int masc_division();
int x = 0;
int y = 0;
int rt = 0;
int counter = 0;
char str[1024];
char sign_str[1024];
int main() {
initStack(&masc__st);
strncpy(str,"test",1024);
str[4] = 0;
begin:
start:
x = 0;
masc_printselection();
if(strcmp(str,"1") == 0) goto addi;
if(strcmp(str,"2") == 0) goto subi;
if(strcmp(str,"3") == 0) goto muli;
if(strcmp(str,"4") == 0) goto divi;
if(strcmp(str,"5") == 0) goto quit;
goto start;
addi:
masc_addition();
counter++;
goto start;
subi:
masc_subtraction();
counter++;
goto start;
muli:
masc_multiplication();
counter++;
goto start;
divi:
masc_division();
counter++;
main();
quit:
goto end;
end:
printf("%s%d%s%s%c","Preformed Exactly ",counter," operations\n ","\nGoodbye!\n",'\0');
x = 5;
do {
doit:
printf("hello world\n");
printf("%d",x);
x--;
} while(x != 0);
Push(&masc__st, 10);
x = (int) Pop(&masc__st);
printf("%d",x);
x = x &  y;
x = x | y;
x = !x;
x = x ^ y;

return 0;
}
int masc_loop_func () {
}
int masc_getnum () {
printf("enter a number: ");
scanf("%d", &x);
printf("enter another number: ");
scanf("%d", &y);
}
int masc_printselection () {
printf("%s%s%c","Simple calculator in MasC\n 1) for addition\n 2) for subtraction\n 3) for multiplication\n 4) for division\n 5) to exit\n","Enter selection: ",'\0');
scanf("%s", str);
return 0;
}
int masc_printresult () {
printf("%d%s%d%s%d%s%c",x,sign_str,y,"=",rt,"\n",'\0');
}
int masc_addition () {
masc_getnum();
rt = x;
rt += y;
sprintf(sign_str, "%s%c","+",'\0');
masc_printresult();
}
int masc_subtraction () {
masc_getnum();
rt = x;
rt -= y;
sprintf(sign_str, "%s%c","-",'\0');
masc_printresult();
}
int masc_multiplication () {
masc_getnum();
rt = x;
rt *= y;
sprintf(sign_str, "%s%c","*",'\0');
Push(&masc__st, (int) x);
masc_printresult();
}
int masc_division () {
num:
masc_getnum();
rt = x;
rt /= y;
sprintf(sign_str, "%s%c","/",'\0');
masc_printresult();
if(strcmp(str,"5")) goto num;
}
