Find the output of the following program.
int main()
{
int n=2;
while(n=100)
{
n = n*n;
}
while(n>100)
{
n = n/2;
}
printf("%d",n);
return 0;
}
Answers
Answered by
0
Answer:
2
Explanation:
Assuming that the first while statement corresponds to this:
while(n==100){
}
we can easily deduce that none of the while loops get executed because the initial value of 'n' is 2. The precondition for the first while loop is (n==100) which is false while the next precondition is (n>100) which is also false. Hence our final output is 2.
Similar questions