Will the while loop terminate If yes after how many iteratio
Will the while loop terminate? If yes, after how many iteration? Does the resukt change if the variables are unsigned integers instead of signed integers?
int i=1;
int c = 1;
while (i>0)
{
i = i * 2;
c++;
}
Solution
Will the while loop terminate?
Yes, it terminates after 32 iterations, when i reaches its max value
if the variables are declared as unsigned integers then the number of iterations are 33
