C प्रोग्राम का आउटपुट क्या है?
What is the output of C Program ?
int main()
{
int k=10;
while(k <= 12)
{
printf("%d ", k);
k++;
}
return 0;
}
A
10 10 10
B
12 12 12
C
10 11 12
D
12 11 10
Explanation
Let's analyze the given C program step by step:
Code:
int main() {
int k = 10;
while (k <= 12) {
printf("%d ", k);
k++;
}
return 0;
}
Explanation:
- Initialization: The variable
kis initialized to 10. - The
whileloop runs as long ask <= 12. It will print the value ofkand then incrementkafter each iteration. - The loop executes three times with
ktaking values 10, 11, and 12.
Iterations:
- First iteration:
k = 10, it prints "10 ", and thenk++makesk = 11. - Second iteration:
k = 11, it prints "11 ", and thenk++makesk = 12. - Third iteration:
k = 12, it prints "12 ", and thenk++makesk = 13. The conditionk <= 12is no longer true, so the loop stops.
Output:
The program will print: "10 11 12"
So, the correct answer is:
(C) 10 11 12.
Correct Answer: C) 10 11 12