tag:blogger.com,1999:blog-959939550345671470.post3877017371590545257..comments2024-03-17T12:50:37.677+05:30Comments on C programming Interview questions and answers: Printf function questions and answer with solutionPriyanka kumarihttp://www.blogger.com/profile/08145649011863585828noreply@blogger.comBlogger85125tag:blogger.com,1999:blog-959939550345671470.post-67519018870944293112017-07-22T12:29:39.487+05:302017-07-22T12:29:39.487+05:30Please give explanation to the answers sir....Please give explanation to the answers sir....Anonymoushttps://www.blogger.com/profile/10691095516537105057noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-53464703615493758732017-07-22T12:17:30.033+05:302017-07-22T12:17:30.033+05:30Please give explanation to the answers sir....Please give explanation to the answers sir....Anonymoushttps://www.blogger.com/profile/10691095516537105057noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-77869186880671303762016-11-03T11:07:07.852+05:302016-11-03T11:07:07.852+05:30For fifth question:
%p and %Fp print out a poi...For fifth question:<br /> %p and %Fp print out a pointer, specifically the address to which the pointer refers, and since it is printing out a part of your computer's architecture, it does so in Hexadecimal.<br />Simply %p is for printing a pointer address. <br /><br /> %Fp is not for pointer, depending on compilers. For gcc/clang, %F is for float, similar to %f with a little different.Anonymoushttps://www.blogger.com/profile/15621431030139513849noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-74073790378424485382016-11-03T11:05:32.868+05:302016-11-03T11:05:32.868+05:30For fifth question:
%p and %Fp print out a poi...For fifth question:<br /> %p and %Fp print out a pointer, specifically the address to which the pointer refers, and since it is printing out a part of your computer's architecture, it does so in Hexadecimal.<br />Simply %p is for printing a pointer address. <br /><br /> %Fp is not for pointer, depending on compilers. For gcc/clang, %F is for float, similar to %f with a little different.Anonymoushttps://www.blogger.com/profile/15621431030139513849noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-36728980697060837642016-09-12T21:41:22.530+05:302016-09-12T21:41:22.530+05:30Can anyone give explanation of 5th questionCan anyone give explanation of 5th questionShinde Balajihttps://www.blogger.com/profile/15015173698028892768noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-55348466728956401892016-08-20T03:41:17.622+05:302016-08-20T03:41:17.622+05:30For question no. 4:
when executed the "%d&quo...For question no. <b>4</b>:<br />when executed the "%d", then "%d" is reserved in heap and allocates total 3 bytes(2 for '%' and 'd' char, 1 for '\0' char) and then returns the address of the first byte (i.e. address of the '%' char), but we know if we increase a char * type pointer then it points the next byte, so now for ("%d" + 1), Anonymoushttps://www.blogger.com/profile/04646487714460964760noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-65914735586292392112016-08-20T03:39:04.659+05:302016-08-20T03:39:04.659+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/04646487714460964760noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-69852201884805464702016-08-01T22:49:06.557+05:302016-08-01T22:49:06.557+05:30hi Surender Naregudam ,printf returns the number o...hi Surender Naregudam ,printf returns the number of characters s0<b>c = printf("%d",a)+ ++b;</b> in this case a has 2 numbers it returns 2 and we are incrementing b by 1 and adding with 2 gives you three.Therefore when you print c it gives 23.Anonymoushttps://www.blogger.com/profile/18370188182908572648noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-38998782659172493482016-04-27T21:40:06.628+05:302016-04-27T21:40:06.628+05:30can u explain how %p and%fp works.!!can u explain how %p and%fp works.!!Anonymoushttps://www.blogger.com/profile/07810176499371239132noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-79796008848337091652016-04-27T21:38:01.938+05:302016-04-27T21:38:01.938+05:30i think itz simply BODMASi think itz simply BODMASAnonymoushttps://www.blogger.com/profile/07810176499371239132noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-16136309523333173362016-04-27T21:36:21.905+05:302016-04-27T21:36:21.905+05:30%d is string and 1 is subscript so answer is obvio...%d is string and 1 is subscript so answer is obviously d<br />Anonymoushttps://www.blogger.com/profile/07810176499371239132noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-60321789686744353062016-02-10T10:05:20.471+05:302016-02-10T10:05:20.471+05:30regarding to gcc compilerregarding to gcc compilerAnonymoushttps://www.blogger.com/profile/13251534394305942216noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-9071800437174015442016-02-10T10:02:56.513+05:302016-02-10T10:02:56.513+05:30here a=10(two digit number)...(%d,a)+ ++b gives ad...here a=10(two digit number)...(%d,a)+ ++b gives add 2 digits to incremented b value thai is 21+2digits=23....( but b value is 21 only).<br /> <br />ex1: a= 100(three digits)...(%d,a)+ ++b gives add 3 digits to incremented b value that is ....21+3=25.....the ans is 1025.....<br />ex2: a=10(two digits) ...(%d\n,a)+ ++b gives add 2 digit + one digit for \n total of three digits.....the ans gives Anonymoushttps://www.blogger.com/profile/13251534394305942216noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-52366668566626164252016-01-22T05:10:41.674+05:302016-01-22T05:10:41.674+05:30First question: it is printed using stack operatio...First question: it is printed using stack operation. So it prints from right to left and we get 11 6 5Anonymoushttps://www.blogger.com/profile/13630962607136082662noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-5640822408538810252015-12-02T16:12:21.202+05:302015-12-02T16:12:21.202+05:30answer: 1023. explain it, ...............please.answer: 1023. explain it, ...............please.Anonymoushttps://www.blogger.com/profile/08251270360777058398noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-43450822102232067672015-12-02T16:11:28.846+05:302015-12-02T16:11:28.846+05:30#include
main()
{
int a, b, c;
...#include<br />main()<br /> {<br /> int a, b, c;<br /> a = 10;<br /> b = 20;<br /> c = printf("%d",a)+ ++b;<br /> printf ("%d",c);<br /> }<br />Anonymoushttps://www.blogger.com/profile/08251270360777058398noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-13033020633884051202015-10-26T19:44:42.402+05:302015-10-26T19:44:42.402+05:30This comment has been removed by the author.Anonymoushttps://www.blogger.com/profile/03829078323417112426noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-61833926450156202362015-07-16T09:55:56.853+05:302015-07-16T09:55:56.853+05:30printf("%d"+1,a); printf("%d k&qu...printf("%d"+1,a); printf("%d k"+3,a); between these two no difference is there. if you give 1 its print 1st offset 'd' & if you give 3 its print 3rd offset 'k'.<br /><br />printf("%d k",+3); //But here the +3 is after the comma operator. So "%d" takes the +3 as argument and prints it.Anonymoushttps://www.blogger.com/profile/06296880128685350829noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-28152757969633915652015-04-30T11:32:30.846+05:302015-04-30T11:32:30.846+05:30can anyone explain 6th questioncan anyone explain 6th questionAnonymoushttps://www.blogger.com/profile/08934613265506071820noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-73501285195111581902014-12-28T10:45:10.740+05:302014-12-28T10:45:10.740+05:30thanks@Anonymousthanks@AnonymousKoushik Ahmedhttps://www.blogger.com/profile/02706532521409169803noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-85178369497336841132014-11-12T21:30:28.117+05:302014-11-12T21:30:28.117+05:30how do we get o/p for 500*500 as -12144 how do we get o/p for 500*500 as -12144 unknownhttps://www.blogger.com/profile/12617271439225091110noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-79167571619933261432014-11-12T21:19:32.019+05:302014-11-12T21:19:32.019+05:30printf("%de %d"+2)output:e 0 and for pri...printf("%de %d"+2)output:e 0 and for printf("%de %d"+2,a)output:e 5.explain?<br />unknownhttps://www.blogger.com/profile/12617271439225091110noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-61714485200996653422014-10-12T02:41:44.047+05:302014-10-12T02:41:44.047+05:30why questiono. 4 gives compilation error why questiono. 4 gives compilation error Anonymoushttps://www.blogger.com/profile/13331531317199681826noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-82422109892538343482014-07-05T23:15:04.218+05:302014-07-05T23:15:04.218+05:30yea it's depend on compiler , in cpp file pick...yea it's depend on compiler , in cpp file pick up a garbage value. Joginder Singhhttps://www.blogger.com/profile/14708779394632671021noreply@blogger.comtag:blogger.com,1999:blog-959939550345671470.post-28212606921139163412014-04-14T21:46:57.369+05:302014-04-14T21:46:57.369+05:301 q ans is wrong1 q ans is wrongAnonymousnoreply@blogger.com