Hi all. I have a problem with my calculator.
#include <stdio.h>
int a, b; /* value entered by user */
char c, choice;
int main()
{
printf("\nThis program is a calculator.\n");
printf("Enter your calculation: ");
scanf("%d%c%d", &a,&c,&b);
if (c=='+')
printf("The answer is %d", a+b);
if (c=='-')
printf("The answer is %d", a-b);
if (c=='*')
printf("The answer is %d", a*b);
if (c=='/')
printf("The answer is %d", a/b);
printf("\n\nDo you want to continue? [Y/N]\n\n");
scanf("%s", &choice);
if(choice=='y'||choice=='Y');
main();
return 0;
}
I am having a problem with ending the program. When I enter a key other than Y, it loops back to the start of the program. How do I exit it?
Thanks in advanced.