Hi! I'm new to C program and my prof gave me this problem Can anybody help me out.
Ok, she wants an output like the one below
--------------------------------
Main Menu
[1] Addition
[2] Subtraction
[3] Multiplication
[4] Divison
Enter your choice: __
-2nd page/another screen
Addition
Enter Number 1 :
Enter Number 2 :
The Sum is _
Try Again? [y][n]
--------------------------------
i should use do while and switch case
and here's what i made
--------------------------------
#include<stdio.h>
#define p printf
#define g gotoxy
#define s scanf
main()
{
char oper,addition,subtraction,multiplication,division;
int num1,num2,total,ch;
clrscr();
g(33,3);p("MAIN MENU");
g(25,5);p("[1] Addition");
g(25,6);p("[2] Subtraction");
g(25,7);p("[3] Multiplication");
g(25,8);p("[4] Division");
g(25,10);p("Enter Your Choice");
do
{
g(25,11);ch=getche();
getche();
}
while(ch!='1' && ch!='2' && ch!='3' && ch!='4');
switch(ch)
{
case '1': oper=addition;
break;
case '2': ch=num1-num2;
oper=subtraction;
break;
case '3': ch=num1*num2;
oper=multiplication;
break;
case '4': ch=num1/num2;
oper=division;
break;
}
clrscr();
g(30,3);p("%s",oper);
g(15,5);p("Number 1 : ");
s("%d",num1);
g(15,6);p("Number 2 : ");
s("%d",num2);
g(15,7);p("Total is %d",ch);
getch();
return 0;
}
-----------------------------------
But it doesn't work. What could be wrong in my program?To anyone who replies, thanks in advance!