[algogeeks] Re: Explain algo behind code

2012-03-06 Thread Gene
Not at the moment as I'm traveling. Sorry. You could start with http://en.wikipedia.org/wiki/Modular_arithmetic . The references might be helpful. I'll illustrate what I"m talking about. Let M=7. Then here is a table of inverses and checks: All mod 7 arithmetic Inverse Check 1 ^ 5 = 1

Re: [algogeeks] Re: Explain algo behind code

2012-03-05 Thread amrit harry
could you refer a number theory book..? On Tue, Mar 6, 2012 at 7:01 AM, Gene wrote: > It's a fact from number theory that > > x * (x^(M-2)) = 1 (mod M) > > if M is prime. So x^(M-2) is the multiplicative inverse of x (mod > M). It follows by identities of modulo arithmetic that > > n!/(r!(n-

[algogeeks] Re: Explain algo behind code

2012-03-05 Thread Gene
It's a fact from number theory that x * (x^(M-2)) = 1 (mod M) if M is prime. So x^(M-2) is the multiplicative inverse of x (mod M). It follows by identities of modulo arithmetic that n!/(r!(n-r)!) = n! * inv(r!) * inv( (n-r)! ) (mod M) This is what the code is computing. A basic number

Re: [algogeeks] Re: explain the output please.....

2011-10-07 Thread Raghav Garg
*yeah..i was wrong as i didn't notice (-) sign .. *Thanking you *With regards- Raghav garg Contact no. 9013201944 www.facebook.com/rock.raghavag B. tech (IT), 5th sem University School Of Information Technology Guru Govind Singh Indraprastha University Delhi* On Sat, Oct 8, 2011 at 8:42 AM, ra

Re: [algogeeks] Re: explain the output please.....

2011-10-07 Thread rahul sharma
o/p : fail 1 between c and u they will be in range so stored as it is but i is -16 converted to 2 complement n become -32 thats y On Sat, Oct 8, 2011 at 2:02 AM, Rahul Tiwari wrote: > o/p - fail1 >pass2 > > xplaination - as char range = (-127 to +127) so char c=-64 is ok > so (c>i) cond

[algogeeks] Re: explain the output please.....

2011-10-07 Thread Rahul Tiwari
o/p - fail1 pass2 xplaination - as char range = (-127 to +127) so char c=-64 is ok so (c>i) condition z not true ..so else part got executed . but u is unsigned so its actual value z , u = some very high + no. so i wrote: > i have run the program in turbo c and getting same o/p as

Re: [algogeeks] Re: EXPLAIN THE OUTPUTS

2011-07-19 Thread rajeev bharshetty
Output on gcc 4.3.x being bfed75a8 3 -1218278705 The First output is the address of the a[0] . Here the function is returning a local address , so the output is compiler dependent . On Tue, Jul 19, 2011 at 8:42 PM, geek forgeek wrote: > @schrodinger y a[] value is not lost in first call.it sh

Re: [algogeeks] Re: EXPLAIN THE OUTPUTS

2011-07-19 Thread geek forgeek
@schrodinger y a[] value is not lost in first call.it should be lost in first call only? On Tue, Jul 19, 2011 at 8:24 PM, schrodinger <6fae1ce6347...@gmail.com>wrote: > First output of memory location is fine. > Second output is also expected one. > Third output will vary compiler to compiler an

[algogeeks] Re: EXPLAIN THE OUTPUTS

2011-07-19 Thread schrodinger
First output of memory location is fine. Second output is also expected one. Third output will vary compiler to compiler and from time to time. This is because a[] is a local to fun(). First time when you call printf("%d\n",r[0]) its fine. but after executing printf() location of r is lost and

[algogeeks] Re: EXPLAIN THE OUTPUTS

2011-07-19 Thread SAMMM
check the O/P :- https://ideone.com/p7pcv Output:- bfc9aae0 (this is always give correct address) 3 // may vary from compiler to compiler (garbage may also come) 3 // may vary from compiler to compiler I think the o/p will depend from compiler to compiler . -- You received this message

[algogeeks] Re: Explain the o/p

2011-06-29 Thread Nishant
in 1st printf no. of characters written are 3 and 4 and 3 & 4 is 0 which is equal to i next 3 printf are easy... now in last printf no. of characters written by 2 printf(s) are 3 and 3 and 3 & 3 is 3 which is printed by outer printf On Jun 29, 7:40 pm, ashwini singh wrote: > please ex-pla

Re: [algogeeks] Re: Explain this.....

2011-06-22 Thread rajeev bharshetty
First the values are calculated from right to left and then the result is printed from left to right. So the last output is 100 in gcc 4.0 compiler. The ptr pointer is calculated initially and then printed. Try first calculating from right to left... On Wed, Jun 22, 2011 at 9:19 PM, udit sharma wr

Re: [algogeeks] Re: Explain this.....

2011-06-22 Thread udit sharma
May be it is compiler dependent.. :) -- 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

[algogeeks] Re: Explain this.....

2011-06-22 Thread RITESH SRIVASTAV
In any function call , the comma operator used is not a sequence point so the order of evaluation of the arguments sent to the function is not defined .That is why it is giving different output on different compilers. On Jun 22, 7:29 pm, Piyush Sinha wrote: > I am using Dev C++ its showing last o

Re: [algogeeks] Re: Explain the o/p

2011-06-16 Thread DIPANKAR DUTTA
This is depending on the precission of floating point number representation (IEEE double pression or single precission ) and how it is handled by the compilers) On Thu, Jun 16, 2011 at 8:50 PM, Kamakshii Aggarwal wrote: > I have read this link,still i am not getting.Can anybody help?? > > On 6/1

Re: [algogeeks] Re: Explain the o/p

2011-06-16 Thread Kamakshii Aggarwal
I have read this link,still my not getting.Can anybody help?? On 6/15/11, Maksym Melnychok wrote: > that's floating point for you. > > http://en.wikipedia.org/wiki/Floating_point > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To vie

Re: [algogeeks] Re: Explain the o/p

2011-06-16 Thread Kamakshii Aggarwal
I have read this link,still i am not getting.Can anybody help?? On 6/16/11, Kamakshii Aggarwal wrote: > I have read this link,still my not getting.Can anybody help?? > > On 6/15/11, Maksym Melnychok wrote: >> that's floating point for you. >> >> http://en.wikipedia.org/wiki/Floating_point >> >>

[algogeeks] Re: Explain the o/p

2011-06-15 Thread Maksym Melnychok
that's floating point for you. http://en.wikipedia.org/wiki/Floating_point -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/RcduUpABmi8J. To post to this gr

[algogeeks] Re: Explain the o/p

2011-06-15 Thread shashankreddy509
i have checked the code in broland 4.5.. i have changed some code and checked ... int main() { *float a=275.6;* printf("%.10f\n",a);//prints 275.7000122070 WHY??? if(275.7>a) printf("Hi"); else printf("Hello"); return 0; } output is 275.661035 and also look at this one as well.. int m

Re: [algogeeks] Re: Explain

2010-09-11 Thread siddharth srivastava
On 10 September 2010 16:25, saurabh agrawal wrote: > Thanks a lot umesh...but still i am in confusion that: > > after first processing : "A is replaced by B" > after second proecessing " B is replaced by A" > then why again this A is not being replaced by #define A macro.. > why it is not going i

Re: [algogeeks] Re: Explain

2010-09-10 Thread Ayush Mittal
first all the preprocessor statementa are executed where all A's are replace by B now the code looks like #include int main(){ int B =4; #define A B #define B B printf("%d",B); return 0; } after words second preprocessor statement get executed and all B's by B get replaced #include int main(){ in

[algogeeks] Re: Explain

2010-09-10 Thread Ukil
Instead of blindly looking for answer, do "gcc -E yourfilename.c". It will produce o/p after preprocessing. See what's happening there? On Sep 10, 3:55 pm, saurabh agrawal wrote: > Thanks a lot umesh...but still i am in confusion that: > > after first processing : "A is replaced by B" > after sec

Re: [algogeeks] Re: Explain

2010-09-10 Thread saurabh agrawal
Thanks a lot umesh...but still i am in confusion that: after first processing : "A is replaced by B" after second proecessing " B is replaced by A" then why again this A is not being replaced by #define A macro.. why it is not going in an infinite loop...because i think there is no fiexed order of

Re: [algogeeks] Re: Explain

2010-09-10 Thread umesh kewat
HI, Here are some fact related to macros.. its a preprocessor directory so before comping the code will replaced by appropriate macros... these are not comping or executing ..so macros replaced one by one and other fact macro will not replaced the content of other macros... so code of 1st code

[algogeeks] Re: Explain

2010-09-10 Thread praveen
After preprocessing Where ever there is 'A' in your program, it is replaced by 'B' Where ever there is 'B' in your program, it is replaced by 'B' this will be the program look like #include int main(){ int B =4; printf("%d",B); return 0; } therefore, the program will compile and run :) -- You