Beginner C/C++

Moderators: None (Apply to moderate this forum)
Number of threads: 5430
Number of posts: 16951

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
o/p of: c = printf("%d%d", a, b); Posted by pnkprz on 4 Jan 2013 at 7:06 AM
int main()
{
int a,b,c;
a=b=5;
c=printf("%d%d",a,b); //line 5
printf("%d",c);
return 0
}

what will be the output of this C program..Please explain how line 5 works.
Report
Re: o/p of: c = printf("%d%d", a, b); Posted by jhavineet974 on 19 Jan 2013 at 12:03 PM
o/p=554
/*line 5-prototype and definition of printf()is defined in stdio.f file
on execution it will first print 55.on executing second printf(),since the return type of printf() is the number of characters(along with format specifier) it has printed and since here 4 values has been printed so 4 will be assigned to c and hence printed out*/



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.