Computer Science, asked by LoveDose01, 5 months ago

What is printed on console?

int main()
{
int a = 0;
while(a)
{
printf("Love");
}

return 0;
}

Answers

Answered by amikkr
0

For this c-ode nothing will be printed on the console.

  • Here in this co-de we can see that given, a=0, on the next line of co-de also given  "while(a) " . So the while loop will be treated as while(0) for that while loop will not be executed.
  • Basically, the TestExpression inside the parenthesis[()] is evaluated by the while loop. If TestExpression is true, statements within the while loop's body will be performed. After then, TestExpression is evaluated once again. The procedure continues until TestExpression is found to be false. The loop finishes if TestExpression is false (ends).
  • If we assign any other value to "a" except 0 this will become an infinite while loop.
Similar questions