//At which value of i will the loop condition be tested for the second time?
main(void)
{
int i = 1;
double weight;
do
{
cout<< "Enter weight ";
cin>> weight;
cin<<endl;
weight = weight + 1;
i = i +1;
}
while (i<=5)
}
/*
Solution: When the loop run first time with i = 1, i becomes 2 as (i = i+1 = 2).
The value of i = 2 is tested first time.
Now, the loop runs with i = 2, and i becomes 3 as (i = i+1 = 3)
Therefore, now i=3 is tested in second run for i=3.
*/
Comments
Leave a comment