[algogeeks] printf

2011-09-03 Thread priya ramesh
what does printf return?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options,

Re: [algogeeks] printf

2011-09-03 Thread Nikhil Gupta
The number of characters printed. On Sat, Sep 3, 2011 at 6:45 PM, priya ramesh love.for.programm...@gmail.com wrote: what does printf return?? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] printf

2011-09-03 Thread priya ramesh
ok thank q :) On Sat, Sep 3, 2011 at 6:51 PM, Nikhil Gupta nikhilgupta2...@gmail.comwrote: The number of characters printed. On Sat, Sep 3, 2011 at 6:45 PM, priya ramesh love.for.programm...@gmail.com wrote: what does printf return?? -- You received this message because you are

[algogeeks] Printf

2011-08-05 Thread anurag
What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base address of the memory iii. Physical address iv. Logical address -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Printf

2011-08-05 Thread Aman Goyal
physical address i suppose... On Fri, Aug 5, 2011 at 1:09 PM, anurag anurag19aggar...@gmail.com wrote: What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base address of the memory iii. Physical address iv. Logical address -- You received this message

[algogeeks] Printf evaluation

2011-07-22 Thread rShetty
#includestdio.h int main() { int i=1; printf(%d%d%d%d,++i,++i,++i,i++); return 0; } Explain how it will be evaluated ?? and the output obtained .. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Prem Krishna Chettri
Values will be Pushed to the Stack from left to right and Evaluated to be finally printed from the Stack. On Fri, Jul 22, 2011 at 4:01 PM, rShetty rajeevr...@gmail.com wrote: #includestdio.h int main() { int i=1; printf(%d%d%d%d,++i,++i,++i,i++); return 0; } Explain how it will

Re: [algogeeks] Printf evaluation

2011-07-22 Thread rajeev bharshetty
Some more explanation taking an example will be helpful take the example in the program. Thanks On Fri, Jul 22, 2011 at 4:03 PM, Prem Krishna Chettri hprem...@gmail.comwrote: Values will be Pushed to the Stack from left to right and Evaluated to be finally printed from the Stack. On Fri,

Re: [algogeeks] Printf evaluation

2011-07-22 Thread suresh srinivasan
Output: 5,4,3,1 *Explanation:* Since the brackets acts as right precedence, the execution of the statement is from right to left. The comma separates the individual. For i++, it prints the current 'i' value and increments it by 1. For ++i, it increments the value by 1 and prints the updated

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Kamakshii Aggarwal
undefined behaviour. since value of i is changing more than once between two sequence points.. On Fri, Jul 22, 2011 at 5:42 PM, suresh srinivasan suree...@gmail.comwrote: Output: 5,4,3,1 *Explanation:* Since the brackets acts as right precedence, the execution of the statement is from

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Gaurav Popli
associativity rule is compiler dependent ...thats why undefined... On Fri, Jul 22, 2011 at 5:46 PM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: undefined behaviour. since value of i is changing more than once between two sequence points.. On Fri, Jul 22, 2011 at 5:42 PM, suresh srinivasan

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Abhinav Verma
There is NO universal way of doing this; every compiler does it differently, in its own ways. The problem here is that the above code changes the value of variable `i' many times between two sequence points. So you cant be sure as to what value `i' holds at what time!!! For more insight and a

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Abhinav Verma
Its not the associativity which is undefined (Associativity has been defined *clearly* by the C Standards for each and every operator). Its the order of evaluation between 2 sequence pointhttp://en.wikipedia.org/wiki/Sequence_points which is undefined and hence compiler-dependent. On gcc version

Re: [algogeeks] Printf evaluation

2011-07-22 Thread Gaurav Popli
may be im wrongbut i read it somewhere about it...the arguments of a function are evaluated in a associativity that is compiler dependent... for ex... printf(%d %d %d ,fun1(),fun2(),fun3()); the order in which functions are evaluated are compiler dependent On Fri, Jul 22, 2011 at 7:20

Re: [algogeeks] Printf evaluation

2011-07-22 Thread shady
so many times such questions have come... behavior is entirely compiler dependent if you are preparing for interviews then believe me no one in the whole world will ask such questions to you. there's no point discussing it On Fri, Jul 22, 2011 at 8:15 PM, Gaurav Popli abeygau...@gmail.com

Re: [algogeeks] Printf ...

2011-07-16 Thread sagar pareek
@Kamakhsi In my ubuntu gcc this o/p is coming with warning of undefined %# :) On Sat, Jul 16, 2011 at 5:43 AM, sukhmeet singh sukhmeet2...@gmail.comwrote: @Anatony the output will be compiler dependent res1 is not defined .. as C don't allow to change the value of a variable more than

Re: [algogeeks] Printf ...

2011-07-16 Thread sagar pareek
and o/p is %#s Zi not %s Zi On Sat, Jul 16, 2011 at 2:18 PM, sagar pareek sagarpar...@gmail.com wrote: @Kamakhsi In my ubuntu gcc this o/p is coming with warning of undefined %# :) On Sat, Jul 16, 2011 at 5:43 AM, sukhmeet singh sukhmeet2...@gmail.comwrote: @Anatony the output will

Re: [algogeeks] Printf ...

2011-07-16 Thread sagar pareek
tell me your output pls On Sat, Jul 16, 2011 at 2:19 PM, sagar pareek sagarpar...@gmail.com wrote: and o/p is %#s Zi not %s Zi On Sat, Jul 16, 2011 at 2:18 PM, sagar pareek sagarpar...@gmail.comwrote: @Kamakhsi In my ubuntu gcc this o/p is coming with warning of undefined %# :)

Re: [algogeeks] Printf ...

2011-07-16 Thread sagar pareek
@Antony res1=++a + ++a + ++a; Well it depends on the compiler but i know how gcc works :) from left to right it will first do addition of first two 'a' before addition it will increment the value of a by two cos of two pre increments. then resulting addition will then be added to the incremented

Re: [algogeeks] Printf ...

2011-07-15 Thread kranthi kumar
Hi, See the below link for detailed explanation of special printf format specifiers in C... http://www.cplusplus.com/reference/clibrary/cstdio/printf/ -- Regards: --- D Kranthi kumar Computer Science Engg. 1st Mtech, IIT Madras. -- You received this message because you

Re: [algogeeks] Printf ...

2011-07-15 Thread sagar pareek
Whats wrong in this? o/p is-- %.#s Zi *%.#s *is printed as usual and *Zi *is printed coz of *%.2s *it will print only 2 characters as written after decimal place. :) It wil ignore 2nd str On Fri, Jul 15, 2011 at 1:31 AM, rShetty rajeevr...@gmail.com wrote: #includestdio.h int main() { char

Re: [algogeeks] Printf ...

2011-07-15 Thread Antony Kotre
can any tell and explain the output of following code #includestdio.h main() { int a =5, b=5; int res1=(++a)+(++a)+(++a); int res2=(++b)+(++b)*10+(++b)*100; printf(%d\n%d\n,res1,res2); } -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Printf ...

2011-07-15 Thread Kamakshii Aggarwal
@sagar:o/p is #s zi..can u explain y? On Sat, Jul 16, 2011 at 1:45 AM, Antony Kotre antonyko...@gmail.com wrote: can any tell and explain the output of following code #includestdio.h main() { int a =5, b=5; int res1=(++a)+(++a)+(++a); int

Re: [algogeeks] Printf ...

2011-07-15 Thread sukhmeet singh
@Anatony the output will be compiler dependent res1 is not defined .. as C don't allow to change the value of a variable more than once between a sequence point.. A sequence point occur while assigning a value , calling a function or returning from it.. Hence both res1 and res2 would give arbitary

[algogeeks] Printf ...

2011-07-14 Thread rShetty
#includestdio.h int main() { char str[] = Zingle Bell Zingle Bell; printf(%.#s %.2s\n,str,str); return 0; } I need the help to figure out the output of the program and please expalin the behaviour of the printf statement here ? -- You received this message because you are subscribed to the