What is the output of printf ("%d")

Questions by suji   answers by suji

Showing Answers 1 - 48 of 48 Answers

prithviraj

  • Sep 23rd, 2005
 

Error: missing variable

  Was this answer useful?  Yes

Balasubramaniam R

  • Sep 24th, 2005
 

It will print either 0 or garbage value. It will not show any error.

Dave

  • Jan 20th, 2006
 

it will print garbage value

swarn kant

  • Mar 14th, 2006
 

This woun't show any error.

This will print 0, no garbage value.

  Was this answer useful?  Yes

paulson paul chambakottukudyil

  • Apr 12th, 2006
 

Usually the output value cannot be predicted. It will not give any error. It will print a garbage value. But if the situation is

main()

{

int a=1,b=2,c=3;

printf("%d");

}

The output will be the value of the last variable, ie. 3

  Was this answer useful?  Yes

shweta

  • May 2nd, 2006
 

void main()

{

int a=1,b=2,c=3;

printf("%d");

getch();

}

Reply to this..

it will not print 3, but still it will print garbage value.

  Was this answer useful?  Yes

badguy

  • May 20th, 2006
 

well the answer depends on various cases....1st of all this problem is in section of C++ questionsso here i go with various cases:case 1: if printf is used and the file is saved as .cpp then the output wud be a garbage value and no error wud be flashed thrcase 2 : instead of using printf if used cout<<"%d"; as this is the standard input-output fuction in C++ the result is ovipusly very simple and this is %d case 3 : again if the file is caved as .c file then once again result of case one wud be thr

  Was this answer useful?  Yes

Anand Somani

  • May 25th, 2006
 

example :int i=1;printf("%d"); -> display 1// int i=1;printf("%d"); -> display 0

  Was this answer useful?  Yes

Seemit Bharti.

  • Jun 16th, 2006
 

its totally implementation dependent. Printf() may print anything, a garbage value. I think current standard does not specify anything on this.

  Was this answer useful?  Yes

jagdish

  • Sep 15th, 2006
 

It will print any value like garbage value.

  Was this answer useful?  Yes

Raj

  • Nov 3rd, 2006
 

no error , Gives 0 or Garbage value most preferably 0.

  Was this answer useful?  Yes

Niranjan

  • Nov 6th, 2006
 

The answer will be Zero.means it prints 0.

  Was this answer useful?  Yes

Indrajit

  • Aug 21st, 2007
 

How can it compile in the first place without any parameter to %d in the format expression specified ?

  Was this answer useful?  Yes

Priyankar Datta

  • Aug 26th, 2007
 

0

I just tried it in VC++

rkoshy

  • Sep 11th, 2008
 

This will produce random output, depending on whatever happened to be on the stack at the time.

  Was this answer useful?  Yes

shibshankar

  • Sep 6th, 2011
 

it will print 0.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions