forked from Shreya1600/Hacktoberfest-C-Program
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSimple_calculator.c
52 lines (50 loc) · 992 Bytes
/
Simple_calculator.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <stdio.h>
//Name - Neeraj Singh
//reg No - 12012889
//batch - k20pt
int main()
{
int choice;
int no1;
int no2;
int output;
printf("Enter first No:");
scanf("%d",&no1);
printf("Enter second No:");
scanf("%d",&no2);
printf("enter your choice :\n");
printf("1 - addition \n");
printf("2 - subtraction\n");
printf("3 - multiplication\n");
printf("4 - division\n");
printf("5 - modulus\n");
scanf("%d",&choice);
switch(choice){
case 1:
output=no1+no2;
printf("the answer is %d", output);
break;
case 2 :
output=no1-no2;
printf("the answer is %d", output);
break;
case 3 :
output=no1*no2;
printf("the answer is %d", output);
break;
case 4 :
if( no2==0){printf("no 2 can't be zero");
break;}
else{output=no1/no2;
printf("the answer is %d", output);
break;}
break;
case 5 :
output = no1 % no2;
printf("the answer is %d", output);
break;
default:
printf("enter the correct choice !");
}
return 0;
}