Re: [algogeeks] printf

2011-09-03 Thread priya ramesh
ok thank q :) On Sat, Sep 3, 2011 at 6:51 PM, Nikhil Gupta wrote: > 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

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 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 algogeeks@googlegroups.com. > To

[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-08-05 Thread Aman Goyal
physical address i suppose... On Fri, Aug 5, 2011 at 1:09 PM, anurag 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 because you ar

[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 alg

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 wrote: > may be im

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:2

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 points which is undefined and hence compiler-dependent. On gcc version

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 bett

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 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 > wrote: >> >> Out

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 wrote: > > Output: > 5,4,3,1 > > *Explanation:* > > Since the brackets acts as right precedence, the execution of the statement > is from right to left

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 value

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 wrote: > 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

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 wrote: > #include > > int main() > { > > int i=1; > printf("%d%d%d%d",++i,++i,++i,i++); > > return 0; > > } > > Explain how it will be evaluated ?

[algogeeks] Printf evaluation

2011-07-22 Thread rShetty
#include 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 algogee

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 v

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 wrote: > and o/p is "%#s Zi" not "%s Zi" > > > On Sat, Jul 16, 2011 at 2:18 PM, sagar pareek wrote: > >> @Kamakhsi >> In my ubuntu gcc this o/p is coming with warning of undefined "%#" :) >> >> On Sat, Jul 16, 2011 at 5

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 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 wrote: > >> @Anatony >> the output will be compiler dependent >> res1

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 wrote: > @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 sequ

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

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 wrote: > can any tell and explain the output of following code > > #include > main() > { int a =5, b=5; > int res1=(++a)+(++a)+(++a); > int res2=(++b)+(++b)*10+(++b)*100; > > printf(

Re: [algogeeks] Printf ...

2011-07-15 Thread Antony Kotre
can any tell and explain the output of following code #include 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 "Algo

Re: [algogeeks] Printf ...

2011-07-14 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 wrote: > #include > int main() > { > char str[] = "Zingle Bell Z

Re: [algogeeks] Printf ...

2011-07-14 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 ar

[algogeeks] Printf ...

2011-07-14 Thread rShetty
#include 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 Googl