-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.c
64 lines (58 loc) · 1.23 KB
/
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
53
54
55
56
57
58
59
60
61
62
63
64
//Wap in c show choice in odd loops and menu driven program
#include<stdio.h>
void main()
{
int choice,num1,num2;
char exit;
do{
printf("~~~~~Menu Wise Calculator~~~~~\n");
printf("1. For Addition Press 1\n");
printf("2. For Substraction Press 2\n");
printf("3. For Division Press 3\n");
printf("4. For Multiplication Press 4\n");
printf("Press Option:");
scanf("%d\N",&choice);
switch(choice)
{
case 1:
system("cls");
printf("Enter Number 1st:");
scanf("%d",&num1);
printf("Enter Number 2nd:");
scanf("%d",&num2);
printf("Sum of Number is :%d",num1+num2);
break;
case 2:
system("cls");
printf("Enter Number 1st:");
scanf("%d",&num1);
printf("Enter Number 2nd:");
scanf("%d",&num2);
printf("Substraction of Number is :%d",num1-num2);
break;
case 3:
system("cls");
printf("Enter Number 1st:");
scanf("%d",&num1);
printf("Enter Number 2nd:");
scanf("%d",&num2);
printf("Division of Number is :%d",num1/num2);
break;
case 4:
system("cls");
printf("Enter Number 1st:");
scanf("%d",&num1);
printf("Enter Number 2nd:");
scanf("%d",&num2);
printf("Multiplication of Number is :%d",num1*num2);
break;
default:
printf("Invalid Choice.\n");
break;
}
printf("\nDo you want to exit[Y/N]:");
fflush(stdin);
scanf("%c",&exit);
system("cls");
}while (exit=='N');
}