Send Close Add comments: (status displays here)
Got it!  This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Statements with while loops


1. Statements with while loops
This page has some examples and questions involving assignment statements with while loops.

2. Example 1
Here is the C code.

Here are the final values of the variables in the program (main).
r == 4 x == 7 p == 35 (before loop) k == 41 z == 0 (before loop)

The final value of variable z is 7. The output is the remainder left over when z is divided by 10, which is 7 (the answer). Here is the output of the C code.


3. Example 2
Here is the C code.

Here are the final values of the variables in the program (main).
r == 7 w == 6 q == 9 c == 45 (before loop) v == 0 (before loop)

The final value of variable v is 37. The output is the remainder left over when v is divided by 10, which is 7 (the answer). Here is the output of the C code.


4. Example 3
Here is the C code.

Here are the final values of the variables in the program (main).
d == 7 n == 5 k == 2 a == 30 (before loop) b == 32 (before loop)

The final value of variable b is 61. The output is the remainder left over when b is divided by 10, which is 1 (the answer). Here is the output of the C code.


5. End of page

6. Multiple choice questions for this page