दिए गए C कोड में, लूप के लिए निष्पादित होता है:
In the given C code, for loop executes for:
#include
void main ()
{
int x=10;
for ( ; ; )
{
printf(“%d\n”,x):
}
}
A)
B)
C)
D)
Explanation:
Let's analyze the provided C code:
Code:
#include
void main() {
int x = 10;
for ( ; ; ) {
printf("%d\n", x);
}
}
Explanation:
-
For Loop Structure: The
for
loop in the code has no condition specified:- The typical structure of a
for
loop is:for(initialization; condition; increment/decrement)
. - In this case, there is no initialization, no condition, and no increment or decrement. This effectively makes it an infinite loop since there is no termination condition.
- The typical structure of a
-
Inside the Loop:
- The value of
x
(which is 10) is printed repeatedly in an infinite loop, with no condition to stop it.
- The value of
Conclusion:
- The loop will run forever because there is no exit condition.
Correct Answer:
(C) infinite.