-
Notifications
You must be signed in to change notification settings - Fork 0
/
test1.c
46 lines (40 loc) · 788 Bytes
/
test1.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
#include <stdio.h>
#include <stdlib.h>
int main()
{
// Defining variable
float num1, num2, cal;
char op;
// Getting inputs and assigning them
printf("Enter the operator: ");
scanf("%c", &op);
printf("Enter first number: ");
scanf("%f", &num1);
printf("Enter second number: ");
scanf("%f", &num2);
// Calculations
if (op == '/')
{
cal = num1 / num2;
printf("%f", cal);
}
else if (op == '*')
{
cal = num1 * num2;
printf("%f", cal);
}
else if (op == '+')
{
cal = num1 + num2;
printf("%f", cal);
}
else if (op == '-')
{
cal = num1 - num2;
printf("%f", cal);
}
else
{
printf("Invalid command or operation");
}
}