Re: [algogeeks] reason
@programming love:I can understand what u say but my doubt is that for the first output which is 2, according to your example, p has address 10 which it points to.And as u say int * tends to dereference 2 bytes so that wud be now 10 and 11.finally char * takes only 1 byte so why is value at 11 address printed( i mean 02) and not value at 10 address( 00) similarly for the second output where u say p+1 goes from 10 to 11 due to char type.when u do int* u say it dereferences 11 and 12. so then when char * is done finally why does it print the one at 12 and not 11? please correct my understanding if wrong On Mon, Aug 15, 2011 at 10:44 AM, programming love < love.for.programm...@gmail.com> wrote: > The internal representation of array is this: > > suppose that the address starts from decimal number 10 and integer occupies > 2 bytes > > 10- 0002 ( num 2 in hex) > 12- 0003 ( num 3 in hex) > 14- 0004 ( num 4 in hex) > > Now p points to address 10 and is type char. (Even after type casts) p+1 > will increment address by 1 byte (since it's char). p will now point to 11 > (int *) will say that when de-referenced 2 bytes should be extracted. So the > 2 bytes extracted are 11, 12. Numbers in these bytes are 02 and 00 > > 10- 00*02* ( num 2 in hex) > 12- *00*03 ( num 3 in hex) > 14- 0004 ( num 4 in hex) > > now (char *) says extract 1 byte for me. The extracted byte is 00. Hence 0 > is printed > > *Correct me if i am wrong.* > > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- "People often say that motivation doesn't last. Well, neither does bathing - that's why we recommend it daily." -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
I believe you are assuming little endian right ? On Mon, Aug 15, 2011 at 2:14 PM, programming love < love.for.programm...@gmail.com> wrote: > The internal representation of array is this: > > suppose that the address starts from decimal number 10 and integer occupies > 2 bytes > > 10- 0002 ( num 2 in hex) > 12- 0003 ( num 3 in hex) > 14- 0004 ( num 4 in hex) > > Now p points to address 10 and is type char. (Even after type casts) p+1 > will increment address by 1 byte (since it's char). p will now point to 11 > (int *) will say that when de-referenced 2 bytes should be extracted. So the > 2 bytes extracted are 11, 12. Numbers in these bytes are 02 and 00 > > 10- 00*02* ( num 2 in hex) > 12- *00*03 ( num 3 in hex) > 14- 0004 ( num 4 in hex) > > now (char *) says extract 1 byte for me. The extracted byte is 00. Hence 0 > is printed > > *Correct me if i am wrong.* > > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- regards, chinna. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
The internal representation of array is this: suppose that the address starts from decimal number 10 and integer occupies 2 bytes 10- 0002 ( num 2 in hex) 12- 0003 ( num 3 in hex) 14- 0004 ( num 4 in hex) Now p points to address 10 and is type char. (Even after type casts) p+1 will increment address by 1 byte (since it's char). p will now point to 11 (int *) will say that when de-referenced 2 bytes should be extracted. So the 2 bytes extracted are 11, 12. Numbers in these bytes are 02 and 00 10- 00*02* ( num 2 in hex) 12- *00*03 ( num 3 in hex) 14- 0004 ( num 4 in hex) now (char *) says extract 1 byte for me. The extracted byte is 00. Hence 0 is printed *Correct me if i am wrong.* -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
I think while assignment the type conversion will take place. Whether you write it or not. check this out: http://ideone.com/y36vj ^^ Just giving off warnings, but it is working. On 15 August 2011 14:14, aditi garg wrote: > I think dis is bec int occupies 4 bytes while char occupies 1 byte so in > the memory when we save as int dey are saved as 2000 3000 4000 > now whn u take a char pointer pointing to dis array and u increment it by 1 > dey will move only by 1 byte and thus u get 0... > u can verify the result by removing char* typecast and u will get the ans > as 2 3 > > > On Mon, Aug 15, 2011 at 1:59 PM, Nitin wrote: > >> #include >> main() >> { >> int arr[3]={2,3,4}; >> char *p; >> p=arr; >> p=(char *)((int *)(p)); >> printf("%d",*p); >> p=(char *)((int *)(p+1)); >> printf("%d",*p); >> } >> it is giving 2,0 why it is giving 0 ..>?? >> >> -- >> 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, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Aditi Garg > Undergraduate Student > Electronics & Communication Divison > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY > Sector 3, Dwarka > New Delhi > > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- ___ Please do not print this e-mail until urgent requirement. Go Green!! Save Papers <=> Save Trees -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
@nitin-- http://www.crazyengineers.com/forum/computer-science-engineering/43458-what-use-c-language.html On Mon, Aug 15, 2011 at 1:51 PM, hary rathor wrote: > > main() > { > int i=6; > do > { > if(i<5) > printf("have fun...","\n"); > }while(i--); > } > > > now you can evaluate your self. > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Anil Kumar Arya B.Tech III year computer science & engineering M.N.N.I.T Allahabad. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
I think dis is bec int occupies 4 bytes while char occupies 1 byte so in the memory when we save as int dey are saved as 2000 3000 4000 now whn u take a char pointer pointing to dis array and u increment it by 1 dey will move only by 1 byte and thus u get 0... u can verify the result by removing char* typecast and u will get the ans as 2 3 On Mon, Aug 15, 2011 at 1:59 PM, Nitin wrote: > #include > main() > { > int arr[3]={2,3,4}; > char *p; > p=arr; > p=(char *)((int *)(p)); > printf("%d",*p); > p=(char *)((int *)(p+1)); > printf("%d",*p); > } > it is giving 2,0 why it is giving 0 ..>?? > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Aditi Garg Undergraduate Student Electronics & Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] reason
#include main() { int arr[3]={2,3,4}; char *p; p=arr; p=(char *)((int *)(p)); printf("%d",*p); p=(char *)((int *)(p+1)); printf("%d",*p); } it is giving 2,0 why it is giving 0 ..>?? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
main() { int i=6; do { if(i<5) printf("have fun...","\n"); }while(i--); } now you can evaluate your self. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
For the first ques the output will be have fun...have fun...have fun...have fun...have fun... dis is because printf will not take into consideration \n because of its format...unless and untill we do not write sm %d or %s or %u etc it wont access the portion of the statement after comma operator... i hope it is clear... On Mon, Aug 15, 2011 at 1:40 PM, Anil Arya wrote: > a##b means you are using the value of ab whatever the value of a and b is > given. > > > On Mon, Aug 15, 2011 at 1:13 PM, Sanjay Rajpal wrote: > >> ## is used for concatenation in C. >> >> >> >> On Mon, Aug 15, 2011 at 12:40 AM, Nitin wrote: >> >>> #include >>> #define fun(arg) do\ >>> {\ >>> if(arg)\ >>> printf("have fun...","\n");\ >>> }while(i--) >>> >>> main() >>> { >>> int i=6; >>> fun(i<5); >>> } >>> >>> give the answer and please give the reason for this >>> >>> #include >>> #define fun(a,b) a##b >>> main() >>> { >>> int a, b, ab; >>> a = 1, b = 2, ab = 3; >>> printf("%d %d", fun(a,b), ab); >>> return -1; >>> >>> } >>> please tell me the use of this # in this program >>> ~ >>> >>> -- >>> 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, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> 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, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Anil Kumar Arya > B.Tech III year > computer science & engineering > M.N.N.I.T Allahabad. > > > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Aditi Garg Undergraduate Student Electronics & Communication Divison NETAJI SUBHAS INSTITUTE OF TECHNOLOGY Sector 3, Dwarka New Delhi -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
a##b means you are using the value of ab whatever the value of a and b is given. On Mon, Aug 15, 2011 at 1:13 PM, Sanjay Rajpal wrote: > ## is used for concatenation in C. > > > > On Mon, Aug 15, 2011 at 12:40 AM, Nitin wrote: > >> #include >> #define fun(arg) do\ >> {\ >> if(arg)\ >> printf("have fun...","\n");\ >> }while(i--) >> >> main() >> { >> int i=6; >> fun(i<5); >> } >> >> give the answer and please give the reason for this >> >> #include >> #define fun(a,b) a##b >> main() >> { >> int a, b, ab; >> a = 1, b = 2, ab = 3; >> printf("%d %d", fun(a,b), ab); >> return -1; >> >> } >> please tell me the use of this # in this program >> ~ >> >> -- >> 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, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Anil Kumar Arya B.Tech III year computer science & engineering M.N.N.I.T Allahabad. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason
## is used for concatenation in C. On Mon, Aug 15, 2011 at 12:40 AM, Nitin wrote: > #include > #define fun(arg) do\ > {\ > if(arg)\ > printf("have fun...","\n");\ > }while(i--) > > main() > { > int i=6; > fun(i<5); > } > > give the answer and please give the reason for this > > #include > #define fun(a,b) a##b > main() > { > int a, b, ab; > a = 1, b = 2, ab = 3; > printf("%d %d", fun(a,b), ab); > return -1; > > } > please tell me the use of this # in this program > ~ > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] reason
#include #define fun(arg) do\ {\ if(arg)\ printf("have fun...","\n");\ }while(i--) main() { int i=6; fun(i<5); } give the answer and please give the reason for this #include #define fun(a,b) a##b main() { int a, b, ab; a = 1, b = 2, ab = 3; printf("%d %d", fun(a,b), ab); return -1; } please tell me the use of this # in this program ~ -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason?????????
u save its output in a file and note nos. from 32676 to a large value < 4294967295 are missing in this.. On Tue, Aug 2, 2011 at 12:59 AM, jagrati verma wrote: > it is nt an infinite loop it ends at 4294967295 > > On Tue, Aug 2, 2011 at 12:53 AM, vijay goswami wrote: > >> its an infinite loop >> >> On Tue, Aug 2, 2011 at 12:21 AM, jagrati verma < >> jagrativermamn...@gmail.com> wrote: >> >>> #include >>> main() >>> { >>> short int i=0; >>> for(i<=5 && i>=-1;++i;i>0) >>> printf("%u\n",i); >>> printf("\n"); >>> return 0; >>> } >>>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, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >> >> -- >> 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, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason?????????
it is nt an infinite loop it ends at 4294967295 On Tue, Aug 2, 2011 at 12:53 AM, vijay goswami wrote: > its an infinite loop > > On Tue, Aug 2, 2011 at 12:21 AM, jagrati verma < > jagrativermamn...@gmail.com> wrote: > >> #include >> main() >> { >> short int i=0; >> for(i<=5 && i>=-1;++i;i>0) >> printf("%u\n",i); >> printf("\n"); >> return 0; >> } >>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, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] reason?????????
its an infinite loop On Tue, Aug 2, 2011 at 12:21 AM, jagrati verma wrote: > #include > main() > { > short int i=0; > for(i<=5 && i>=-1;++i;i>0) > printf("%u\n",i); > printf("\n"); > return 0; > } >o/p is 1. > 4294967295 hw??? > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] reason?????????
#include main() { short int i=0; for(i<=5 && i>=-1;++i;i>0) printf("%u\n",i); printf("\n"); return 0; } o/p is 1. 4294967295 hw??? -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
Re: [algogeeks] Reason for banning
only reason why any of the moderators must have banned you is either for advertising kind of mails, or abusive mails, spamming.. "I hope I get a reply to this instead of this ID also getting banned" oh come on there must have been something that got you banned, anyway you are not banned anymore. :) On Wed, Jul 6, 2011 at 2:41 AM, Sanket wrote: > Hi, > > I was using a different ID for browsing and commenting on this group > but since yesterday, I am getting a notification that the moderator > has banned me from using this group. I wanted to know the reason why I > was banned and whether this was in error because I don't remember > doing anything which would warrant being banend. All I did was comment > with solutions to problems posted by other group members - in case a > spam mail went out from my account, kindly let me know. My email id > which was banned was vasa.san...@gmail.com > > I hope I get a reply to this instead of this ID also getting banned > because I really valued being part of this group and learning from the > informative discussions that it provides. > > -- > 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, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.
[algogeeks] Reason for banning
Hi, I was using a different ID for browsing and commenting on this group but since yesterday, I am getting a notification that the moderator has banned me from using this group. I wanted to know the reason why I was banned and whether this was in error because I don't remember doing anything which would warrant being banend. All I did was comment with solutions to problems posted by other group members - in case a spam mail went out from my account, kindly let me know. My email id which was banned was vasa.san...@gmail.com I hope I get a reply to this instead of this ID also getting banned because I really valued being part of this group and learning from the informative discussions that it provides. -- 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, visit this group at http://groups.google.com/group/algogeeks?hl=en.