-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGCOV
87 lines (83 loc) · 3.85 KB
/
GCOV
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
https://codeflu.blog/2015/01/16/finally-integrating-gcov-and-lcov-tool-into-cppagent-build-process/
$g++ -o menu.out --coverage menu.cpp
$lcov -t "result" -o ex_test.info -c -d .
$genhtml -o res ex_test.info
#include <iostream>
2 : using namespace std;
3 :
4 : void showChoices();
5 : float add(float, float);
6 : float subtract(float, float);
7 : float multiply(float, float);
8 : float divide(float, float);
9 :
10 2 : int main()
11 : {
12 : float x, y;
13 : int choice;
14 2 : do
15 : {
16 2 : showChoices();
17 2 : cin >> choice;
18 2 : switch (choice)
19 : {
20 : case 1:
21 0 : cout << "Enter two numbers: ";
22 0 : cin >> x >> y;
23 0 : cout << "Sum " << add(x,y) <<endl;
24 0 : break;
25 : case 2:
26 0 : cout << "Enter two numbers: ";
27 0 : cin >> x >> y;
28 0 : cout << "Difference " << subtract(x,y) <<endl;
29 0 : break;
30 : case 3:
31 0 : cout << "Enter two numbers: ";
32 0 : cin >> x >> y;
33 0 : cout << "Product " << multiply(x,y) <<endl;
34 0 : break;
35 : case 4:
36 1 : cout << "Enter two numbers: ";
37 1 : cin >> x >> y;
38 1 : cout << "Quotient " << divide(x,y) <<endl;
39 1 : break;
40 : case 5:
41 1 : break;
42 : default:
43 0 : cout << "Invalid input" << endl;
44 : }
45 2 : }while (choice != 5);
46 :
47 1 : return 0;
48 : }
49 :
50 2 : void showChoices()
51 : {
52 2 : cout << "MENU" << endl;
53 2 : cout << "1: Add " << endl;
54 2 : cout << "2: Subtract" << endl;
55 2 : cout << "3: Multiply " << endl;
56 2 : cout << "4: Divide " << endl;
57 2 : cout << "5: Exit " << endl;
58 2 : cout << "Enter your choice :";
59 2 : }
60 :
61 0 : float add(float a, float b)
62 : {
63 0 : return a+b;
64 : }
65 :
66 0 : float subtract(float a, float b)
67 : {
68 0 : return a-b;
69 : }
70 :
71 0 : float multiply(float a, float b)
72 : {
73 0 : return a*b;
74 : }
75 :
76 1 : float divide(float a, float b)
77 : {
78 1 : return a/b;
79 3 : }