COMP2113
COMP2113_ENGG1340 Programming technologies and Computer programming II [Section 2BC] [2023]
Loading...
Searching...
No Matches
checkpoint5.2.cpp
Go to the documentation of this file.
1#include <iostream>
2using namespace std;
3
4void g(int& k);
5
6int main(){
7 int y = 9;
8 int x = 7;
9 int i = 0;
10
11 while (i < 3){
12 if (i % 2 == 0){
13 g(x);
14 i++;
15 }
16 else{
17 g(y);
18 i++;
19 }
20 }
21}
22
23void g(int& k){
24 static int num = 6;
25
26 if (k % 2 == 0){
27 num += 2;
28 k = k + 6;
29 }
30 else{
31 num -= 2;
32 k = k - 6;
33 }
34 cout << num << ", " << k << endl;
35}
void g(int &k)
int main()