दिए गए C कोड में, लूप के लिए निष्पादित होता है:
In the given C code, for loop executes for:
#include
void main ()
{
int x=10;
for ( ; ; ) { printf(“%d\n”,x):}
}
A
10 times
B
9 times
C
infinite
D
Zero
Explanation
Let's analyze the given C code:
Code:
#include
void main() {
int x = 10;
for( ; ; ) {
printf("%d\n", x);
}
}
Explanation:
-
The
forloop here has no conditions, meaning it doesn't have a start, end, or increment condition. This is an infinite loop.- The empty loop structure (
for( ; ; )) means the loop will continue executing indefinitely unless there is some external condition (like abreakor other exit mechanism).
- The empty loop structure (
-
Inside the loop, the statement
printf("%d\n", x);will continuously print the value ofx, which is 10 in this case, on each iteration.
Conclusion:
Since the loop has no terminating condition, it will run indefinitely, printing the value of x (which is 10) continuously.
Thus, the output of this code will be an infinite loop.
Correct Answer:
(C) infinite.
Correct Answer: C) infinite