Created
February 22, 2015 18:00
-
-
Save najikadri/044177b5187025cfe3fa to your computer and use it in GitHub Desktop.
simple calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
int main( void) | |
{ | |
int a,b,sum,option; | |
printf("Welcome to C calculator\n"); | |
printf("Choose an option:\n"); | |
printf("add: 1 , Subtract: 2 , Multiply: 3\n"); | |
scanf("%d",&option); | |
printf("Set first number:\n"); | |
scanf("%d",&a); | |
printf("Set second number:\n"); | |
scanf("%d",&b); | |
switch (option) { | |
case 1: sum = a + b; printf("Result is: %d\n", sum); break; | |
case 2: sum = a - b;printf("Result is: %d\n", sum); break; | |
case 3: sum = a * b;printf("Result is: %d\n", sum); break; | |
default: printf("Wrong option selected!"); break; | |
} | |
printf("\nPress Any Key To Continue...\n"); | |
getch(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment