-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheasiestcalc.c
69 lines (49 loc) · 1.3 KB
/
easiestcalc.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
65
66
67
68
#include <stdio.h>
#include <stdlib.h>
float addition(float a, float b);
float subtraction(float a, float b);
float multiplication(float a, float b);
float division(float a, float b);
void main()
{
float x = 0;
float d = 0;
char operation;
printf("Hello traveler!\n");
printf("Please enter the first number:\n");
scanf("%f", &x);
printf("Please enter the second number:\n");
scanf("%f", &d);
printf("Please enter the symbol of the operation you would like to do:\n");
operation = getch();
printf("%c\n", operation);
switch(operation){
case 43:
addition(x, d);
printf("The result of this operation is: %.2f", addition(x, d));
break;
case 45:
printf("The result of this operation is: %.2f", subtraction(x, d));
break;
case 42:
printf("The result of this operation is: %.2f", multiplication(x, d));
break;
case 47:
printf("The result of this operation is: %.2f", division(x, d));
break;
deafult:
printf("You have entered an incorrect symbol.");
}
}
float addition(float a, float b){
return a + b;
}
float subtraction(float a, float b){
return a - b;
}
float multiplication(float a, float b){
return a * b;
}
float division(float a, float b){
return a / b;
}