-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.c
More file actions
35 lines (35 loc) · 929 Bytes
/
2.c
File metadata and controls
35 lines (35 loc) · 929 Bytes
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
#include <stdio.h>
int main()
{
float num1, num2, sum, sub, multi, divi; //program for basic addition,subtraction,multiplication and division//
int op;
printf("enter the first number:\n");
scanf("%f", &num1);
printf("enter the second number:\n");
scanf("%f", &num2);
printf("enter the operation you want:(press 1 for addition,2 for subtraction,3 for multiplication,4 for division)\n");
scanf("%d", &op);
switch (op)
{
case 1:
sum = num1 + num2;
printf("%f", sum);
break;
case 2:
sub = num1 - num2;
printf("%f", sub);
break;
case 3:
multi = num1 * num2;
printf("%f", multi);
break;
case 4:
divi = num1 / num2;
printf("%f", divi);
break;
default:
printf("the entered operation is not valid");
break;
}
return 0;
}