-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.c
50 lines (40 loc) · 895 Bytes
/
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
#include <stdio.h>
int main () {
int x;
int y;
float result;
int z;
printf ("Enter First number : ");
scanf("%d",&x);
printf ("Enter 2nd number : ");
scanf("%d",&y);
printf ("Your Input data is %d & %d \n ",x,y);
printf ("1 for Addition \n 2 for substraction \n 3 for Multiply \n 4 for Divition \n");
printf ("Please select any options Bellow \n");
scanf("%d",&z);
while ( z >= 5 )
{
printf ("Please select any valid options\n");
scanf("%d",&z);
}
if ( z == 1 )
{
result = (x + y);
printf ( "The Addition value is %f \n",x,y,result);
}
if ( z == 2 )
{
result = (x - y);
printf ( "The substract value is %f \n",x,y,result);
}
if ( z == 3 )
{
result = (x * y);
printf ( "The Multiply value is %f \n",x,y,result);
}
if ( z == 4 )
{
result = (x / y);
printf ( "The Divition value is %f \n",x,y,result);
}
}