what will be the output of the following code?
#include<stdio.h>
void main()
ve!
{
int a = 0;
while(a)
{
printf("C Program");
}
}
Answers
Answered by
2
Answer:
Hi mate,
Here is your answer
Please mark it as brainleast
Explanation:
The code will not give any error and compile successfully. As you see it will not enter into while loop because you have given false value(i.e., is 0) in condition so the loop will fails to execute the code inside the loop(will not enter into the loop) and prints the next line.
*The while loop will continue to execute code inside the loop for true values(a non-zero value).
#include<stdio.h>
void main()
{
int i = 0, j = 0, k = 1;
while(i == 0)
{
printf("in while loop i = %d\n", i);
break;
}
while(j == 0)
{
printf("in while loop j = %d\n", j);
break;
}
while(k < 2)
{
printf("in while loop k = %d\n", k);
break;
}
}
Similar questions
Math,
3 months ago
Math,
3 months ago
Physics,
6 months ago
Social Sciences,
6 months ago
Computer Science,
10 months ago