Question: Lab 5 Tracing Program CSCI 111 Programming and Algorithms I Due Friday February 5, 11:59pm on turnin 10 Points OBJECTIVE: This lab covers the do-while
Lab 5
Tracing Program
CSCI 111 Programming and Algorithms I
Due Friday February 5, 11:59pm on turnin
10 Points
OBJECTIVE: This lab covers the do-while statement.
Recall the Tracing Exercise we did in class. Here it is again.
Directions: Start at step 1 and trace the contents of X, Y, and Z until you reach Step 8.
1. X = 2
2. Z = 1
3. Y = X + 3
4. X = Z * Y
5. Y = Z 4
6. Z = Z + 1
7. If the value of Z is less than 4, return to step 3
8. What are the values of X, Y, and Z?
And here is the code we covered in class to perform the above pseudo code.
#include
using namespace std;
int main()
{
int x;
int y;
int z;
x = 2;
z = 1;
do .
{
y = x + 3;
x = z * y;
y = z - 4;
z = z + 1;
} while ( z < 4 );
cout << "The value of x is " << x << endl;
cout << "The value of y is " << y << endl;
cout << "The value of z is " << z << endl;
return 0;
}
Recall the correct results were x = 57, y = -1, and z= 4
Task list:
1. Enter / compile / execute the above code to ensure you have a good understanding.
2. Get more practice by tracing the pseudo code below. Ensure you get the correct answer which is listed below under the sample output.
Directions: Start at step 1 and trace the contents of X, Y, and Z until you reach Step 8.
1. X = 2
2. Z = 8
3. Y = X * 2
4. X = Z + Y
5. Y = Z 3
6. Z = Z - 1
7. If the value of Z is greater than 5, return to step 3
8. What are the values of X, Y, and Z?
3. Adapt the source code listed above into a file named lab5.cpp such that it performs the 8 lines of pseudo-code listed in the previous step.
4. Compile and execute the code.
5. Confirm that the output of your code matches the format of the output below.
6. If you are working on this lab remotely, then transfer the lab5.cpp code from jaguar to your laptop.
7. Submit your lab5.cpp file on https://turnin.ecst.csuchico.edu/
8. Ensure that you get a successful message after submitting work via turnin.
GRADING
To achieve a maximum score, students will need to clearly prove that they completed the goal.
Points lost for incompleteness, sloppiness, lateness, or failure to follow instructions.
Refer to syllabus for late policy. .
SAMPLE OUTPUT
jraigoza@ecc-jaguar:~/csci111/lab5$ ./lab5
The value of x is 68
The value of y is 3
The value of z is 5
jraigoza@ecc-jaguar:~/csci111/lab5$
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
