Q1. Consider (Any language — for this question, just using “print” to output)
int x = 6;
int y = 12;
while(x < y) {
print “In the while loop”;
x+=2;
y-=2;
}
How many times is the statement “In the while loop” printed?
a) 1
b) 2
c) 3
d) 4
e) 5
Q2. Write “while” loop to repeatedly print the value of the variable z, decreasing it by 0.5 each time, as long
as z remains positive.
N.B. You can use C++ or any other language you’re comfortable with.