Consider the following C++ code segment below.
1 int result(int valueP)
2 {
3 int a = 2;
4 int count = 0;
5 while (count < valueP)
6 {
7 a += count + a / 2;
8 count += 2;
9 }
10 return a;
11 }
Demonstrate the execution and output of the program by drawing a variable diagram that traces each line of code if the value of valueP is 6. You are required to draw a variable diagram to illustrate what the code does.
Return value is 13
Comments
Leave a comment