🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

कोड के निम्नलिखित भाग का आउटपुट क्या होगा?

What will be the output of the following piece of code?


#include <stdio.h>
int main() {
for(i = 0;i < 8; i++);
printf("%d", i);
return 0;
}
A
0
B
1234567
C
8
D
infinite loop
Explanation

Let's break down the given code:

Code:

#include 

int main() {
    for(i = 0; i < 8; i++);
    printf("%d", i);
    return 0;
}

Explanation:

  • The for loop:
    The for loop has a semicolon (;) after it, which means the loop doesn't contain any body (it's an empty loop). It simply increments i from 0 to 7.

  • After the loop completes, i will be 8, because the loop condition (i < 8) fails when i reaches 8.

  • The printf("%d", i); statement:
    This prints the value of i, which is 8 after the loop terminates.

Output:

So, the output of this code will be:

(C) 8.

Correct Answer: C) 8

Latest Updates