A calculator program

#include
#include

int main(){
int num1, num2, choice;

printf(“Choose an operation\n\n”);
printf(“[1] Add\n[2] Subtract\n[3] Multiply\n[4] Divide\n[5] Exit\n”);
scanf(“%d”, &choice);

switch(choice){
case 1:
printf(“Enter 1st number:\n”);
scanf(“%d”, &num1);
printf(“Enter 2nd number:\n”);
scanf(“%d”, &num2);
printf(“\n%d”, (num1+num2));
break;
case 2:
printf(“Enter 1st number:\n”);
scanf(“%d”, &num1);
printf(“Enter 2nd number:\n”);
scanf(“%d”, &num2);
printf(“\n%d “, (num1-num2));
break;
case 3:
printf(“Enter 1st number:\n”);
scanf(“%d”, &num1);
printf(“Enter 2nd number:\n”);
scanf(“%d”, &num2);
printf(“\n%d”, (num1*num2));
break;
case 4:
printf(“Enter 1st number:\n”);
scanf(“\n%d”, &num1);
printf(“Enter 2nd number:\n”);
scanf(“%d”, &num2);
printf(“\n%d”, (num1/num2));
break;
case 5:
return 0;
default:
printf(“That is not a valid choice.”);
break;
}
return 0;
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s