Knowee
Questions
Features
Study Tools

What is The Output of the following    program?  #include<stdio.h>void main(){int  i = printf("00");  int i =printf("00"); printf("%d",i);}000002Garbage value

Question

What is The Output of the following    program?  #include<stdio.h>void main(){int  i = printf("00");  int i =printf("00"); printf("%d",i);}000002Garbage value

🧐 Not the exact question you are looking for?Go ask a question

Solution

The code you've provided is written in C language. However, it contains a syntax error. You are declaring the variable 'i' twice.

Here is the corrected version of your code:

#include<stdio.h>
void main(){
    int i = printf("00"); 
    printf("%d",i);
}

The printf function returns the number of characters printed. So, in this case, it prints "00" and returns 2 (the number of characters printed).

So, the output of the corrected program will be:

002

It first prints "00" from the printf("00"), then it prints "2" from the printf("%d",i); because 'i' holds the value 2 which is the number of characters printed by the previous printf statement.

This problem has been solved

Similar Questions

What is the output of the following C Program?

What is the output for the following code?

What is the output of the following Java program?

What will be the output of the following C++ code?

What is the output of the following code in Python?

1/4

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.