[algogeeks] Re: output

2013-12-09 Thread Don
Printf will print one value per item in the format string. If you don't supply that many, it will look at the undefined memory where that value should have been, so you will get gibberish. Don On Friday, December 6, 2013 9:17:36 AM UTC-5, segfault wrote: > > Hi All, > > I'm not able to get output

Re: [algogeeks] Re: Output

2012-11-25 Thread Rahul Kumar Patle
@pandey : here you are shifting 1 to right by 4 bit (as rushiraj said correctly) which becomes 0.1, then you are doing negation which becomes 11...0(mask) now do you and operation mask & 56 = 40 mask & 64 = 64 mask & 127 = 111 you can notice that only 5th lsb (effective value 1

Re: [algogeeks] Re: Output

2012-11-25 Thread Rahul Kumar Patle
sorry its left shift.. one mistake.. other than this ans is correct.. i have done left shift on 1 by 4 bits that why result became ~(0.1) ignore the right shift i have mentioned.. On Sun, Nov 25, 2012 at 4:48 PM, Rahul Kumar Patle < patlerahulku...@gmail.com> wrote: > @pandey : here y

Re: [algogeeks] Re: Output

2012-11-25 Thread rajesh pandey
thanks @Dave n Rushiraj I think I have got the solution . 1<<5-1 will be evaluated like 1<<(5-1). it will be 16. Now the negation of 0001 will be 1110 and this will be my mask. so for 56 --> 000111000 & 111...0 = 000...101000 => 40. for 64 --> 000...100 & 111.

[algogeeks] Re: Output

2012-11-24 Thread Dave
@Rajesh: In binary, mask = 111...10 (with 4-byte ints, this is 27 1-bits followed by 5 0-bits). The logical product of num with mask zeros out the low order 5 bits while retaining the high order 27 bits. Thus, res is num truncated to the largest multiple of 32 that does not exceed num. 56 =

[algogeeks] Re: output

2012-07-25 Thread deepikaanand
sent... On Wednesday, July 25, 2012 9:18:46 PM UTC+5:30, jatin wrote: > > Trie ??if u have it to mail kardio... > On Wednesday, 25 July 2012 21:10:55 UTC+5:30, deepikaanand wrote: >> >> @ jatin >> then there is something wrong I executed d same prog which I have pasted >> here...it was giving m

Re: [algogeeks] Re: output

2012-07-25 Thread Prem Krishna Chettri
Well Guys, M here just to show wats hpning.. Have your own views.. 1> Everything is right till While loop.. I mean p1 pointing to the heap of the address of the String "Name" , P1 getting 20 bytes of memory chunk and so on.. So here we go now. As this Stupid looking while is culprit he

[algogeeks] Re: output

2012-07-25 Thread jatin
Trie ??if u have it to mail kardio... On Wednesday, 25 July 2012 21:10:55 UTC+5:30, deepikaanand wrote: > > @ jatin > then there is something wrong I executed d same prog which I have pasted > here...it was giving me the correct answer and for the second qs has no > absolute answer it depends o

[algogeeks] Re: output

2012-07-25 Thread deepikaanand
@ jatin then there is something wrong I executed d same prog which I have pasted here...it was giving me the correct answer and for the second qs has no absolute answer it depends on compiler -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" gro

[algogeeks] Re: output

2012-07-25 Thread jatin
On Wednesday, 25 July 2012 20:59:47 UTC+5:30, jatin wrote: > > For the first o/p even though i save it like u have done then too it's > showing me an empty string . > for 2nd as Vindya has stated it should give me error but my compiler is > showing me 30 as it's output(the ans shd be 25 if n

[algogeeks] Re: output

2012-07-25 Thread jatin
For the first o/p even though i save it like u have done then too it's showing me an empty string . for 2nd as Vindya has stated it should give me error but my compiler is showing me 30 as it's output(the ans shd be 25 if not error) ? On Wednesday, 25 July 2012 20:42:56 UTC+5:30, deepikaanand

[algogeeks] Re: output

2012-07-25 Thread jatin
On Wednesday, 25 July 2012 20:20:02 UTC+5:30, jatin wrote: > > anybdy has basic trie implementation (insertion and printing) ? > o/p > 1) > main() > { > char *p1="Name"; > char *p2; > p2=(char *)malloc(20); > while(*p2++=*p1++); > printf("%s\n",p2); > } ...it's giving me empty string > > 2) > i

Re: [algogeeks] Re: output

2012-07-25 Thread vindhya chhabra
for the first, p2 has moved beyond null character, so do char *c=p and then print string for c. for second , since the same object is modified more than once between two sequence points, so it gives compiler dependent answer.if it wud have been i++||i++ , then the answer would have been defined as

[algogeeks] Re: output

2012-07-25 Thread deepikaanand
for the first o/p qs as p1 is moving towards the NULL('\0') character so is p2...to avoid dis save the base address and den let p2 move forward with p1 char *p1="Name"; char *p2; p2=(char *)malloc(20); char *save; save = (char *)malloc(20); save = p2; if(p2==NULL) cout<<"\n NOT ENOUGH SPACE"; els

Re: [algogeeks] Re: output expalnation?

2011-09-26 Thread Sanjay Rajpal
Compilation error. Definition of b is skipped by Switch statement. so 'b' not declared/defined error will occur. Correct me if m wrong. Sanju :) On Mon, Sep 26, 2011 at 6:38 PM, deepikaanand wrote: > junk value cz b=6 will not get executed > > -- > You received this message because you are su

[algogeeks] Re: output expalnation?

2011-09-26 Thread deepikaanand
junk value cz b=6 will not get executed -- 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. Fo

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread Dipankar Patro
Interesting thing I came across: http://stackoverflow.com/questions/1239938/c-accesses-an-array-out-of-bounds-gives-no-error-why On 18 August 2011 09:39, vartika aggarwal wrote: > Is it that there is no bounds checking in C while there is in C++ ? > > > On Thu, Aug 18, 2011 at 9:27 AM, Dipankar P

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread vartika aggarwal
Is it that there is no bounds checking in C while there is in C++ ? On Thu, Aug 18, 2011 at 9:27 AM, Dipankar Patro wrote: > Thats new.. > Its not working in C++, where as in C it works like a charm. > > On 18 August 2011 08:57, vartika aggarwal > wrote: > >> @Aditi: That's because you haven

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread Dipankar Patro
Thats new.. Its not working in C++, where as in C it works like a charm. On 18 August 2011 08:57, vartika aggarwal wrote: > @Aditi: That's because you haven't changed the language to 'C' (while > working on ideone. It doesn't give an error in C) > > > On Thu, Aug 18, 2011 at 8:47 AM, aditi garg w

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread vartika aggarwal
@Aditi: That's because you haven't changed the language to 'C' (while working on ideone. It doesn't give an error in C) On Thu, Aug 18, 2011 at 8:47 AM, aditi garg wrote: > @payal: im getting compile time errors fr both the strings... > Chk dis :http://ideone.com/BRbkf > > > On Thu, Aug 18, 2011

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread aditi garg
@payal: im getting compile time errors fr both the strings... Chk dis :http://ideone.com/BRbkf On Thu, Aug 18, 2011 at 4:12 AM, payal gupta wrote: > i modified the code a lil bit > #include > #include > int main() > { clrscr(); > char arr[5] = "geeks"; > printf("%s\n", arr); > char b[1]="t";

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread payal gupta
i modified the code a lil bit #include #include int main() { clrscr(); char arr[5] = "geeks"; printf("%s\n", arr); char b[1]="t"; printf("%s\n",b); getchar(); return 0; } the output in dis case is somewhat diff..cud someone explain... On Thu, Aug 18, 2011 at 3:28 AM, Ayush Kapoor wrote: >

Re: [algogeeks] Re: Output?? Why??

2011-08-17 Thread Ayush Kapoor
There is no null character in this string,as its length is 5 and the number of characters is 5(Geeks),and printf("%s",arr) should output the string till the null character On Thu, Aug 18, 2011 at 2:40 AM, bihari wrote: > upto null charchter.. > > -- > You received this message becaus

[algogeeks] Re: Output?? Why??

2011-08-17 Thread bihari
upto null charchter.. -- 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

Re: [algogeeks] Re: output???

2011-08-06 Thread saurabh singh
yeah right.. On Sat, Aug 6, 2011 at 12:03 PM, sagar pareek wrote: > Ok thats a diff thing > but what i posted is somewhat different > > actually what happen is that .5 can be represented completely in binary > form and the same case with 1.0 and .25 , .125 also > but when we talk about .7 th

Re: [algogeeks] Re: output???

2011-08-05 Thread sagar pareek
Ok thats a diff thing but what i posted is somewhat different actually what happen is that .5 can be represented completely in binary form and the same case with 1.0 and .25 , .125 also but when we talk about .7 then it cant be represented in binary precisely even we upgrade it to double. thats wh

Re: [algogeeks] Re: output???

2011-08-05 Thread saurabh singh
a double has a higher precision than float i.e. it has larger number of bits for the mantisa part. when float is compared to double it is promoted to double by filling remaining bits in mantissa with 0. consider this code http://ideone.com/y1Ahu Its equal bcoz the

Re: [algogeeks] Re: output???

2011-08-05 Thread sagar pareek
@saurabh what? i didnt get you On Sat, Aug 6, 2011 at 10:22 AM, saurabh singh wrote: > IEEE notation.. > they appear to be the same but they are not same..0.5d has higher > precision that does not necessarily means its larger.. > > > On Sat, Aug 6, 2011 at 10:20 AM, sagar pareek wro

Re: [algogeeks] Re: output???

2011-08-05 Thread saurabh singh
IEEE notation.. they appear to be the same but they are not same..0.5d has higher precision that does not necessarily means its larger.. On Sat, Aug 6, 2011 at 10:20 AM, sagar pareek wrote: > see what piyush posted > > > On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain wrote: > >> s

Re: [algogeeks] Re: output???

2011-08-05 Thread sagar pareek
see what piyush posted On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain wrote: > sagar - i dint get u, d code thing! > > Shashank Jain > IIIrd year > Computer Engineering > Delhi College of Engineering > > > > On Sat, Aug 6, 2011 at 2:31 AM, sagar pareek wrote: > >> yup exactly >> >> On Sat, Au

Re: [algogeeks] Re: output???

2011-08-05 Thread Shashank Jain
sagar - i dint get u, d code thing! Shashank Jain IIIrd year Computer Engineering Delhi College of Engineering On Sat, Aug 6, 2011 at 2:31 AM, sagar pareek wrote: > yup exactly > > On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor wrote: > >> I think it is because the numbers like 0.7 do not hav

Re: [algogeeks] Re: output???

2011-08-05 Thread sagar pareek
yup exactly On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor wrote: > I think it is because the numbers like 0.7 do not have a exact binary > representation,so they are not exactly represented in float,while the > constant is internally implemented as double.,Read this:: > http://www.topcoder.com/t

Re: [algogeeks] Re: output???

2011-08-05 Thread Piyush Kapoor
I think it is because the numbers like 0.7 do not have a exact binary representation,so they are not exactly represented in float,while the constant is internally implemented as double.,Read this:: http://www.topcoder.com/tc?module=Static&d1=tutorials&d2=integersReals -- *Regards,* *Piyush Kapoo

Re: [algogeeks] Re: output???

2011-08-05 Thread sagar pareek
@vikas first read what i wrote On Sat, Aug 6, 2011 at 12:59 AM, vikash wrote: > its due to precision limit of double is larger than float, and by > default real values are stored as double so constant 0.7 is stored > more accurately(8 bytes) that float a=0.7 (4 bytes). and when > comparing the

[algogeeks] Re: output???

2011-08-05 Thread vikash
its due to precision limit of double is larger than float, and by default real values are stored as double so constant 0.7 is stored more accurately(8 bytes) that float a=0.7 (4 bytes). and when comparing the two float is typecasted into double and so the ramaining bits are padded with 0 so 0.7 >

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
@abhinav:thanks.:) On Wed, Jul 27, 2011 at 9:23 PM, Abhinav Arora wrote: > Look we wish to allocate memory for an array of 3 integer pointers. > so when we do dynamic allocation we always store the result in a pointer to > the required data type. > for example if you wish to dynamically allocate

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Abhinav Arora
Look we wish to allocate memory for an array of 3 integer pointers. so when we do dynamic allocation we always store the result in a pointer to the required data type. for example if you wish to dynamically allocate int arr[3[] u will write : int *p=malloc(3*sizeof(int)); So now when you do it f

[algogeeks] Re: OUTPUT

2011-07-27 Thread amit
Hmm, I don't get the question. >> how to dynamically allocate memory for int *a[3]; ? What do you mean by allocating memory for int *a[3]; Can you explain in some more details what exactly you want to do On Jul 27, 8:39 pm, Kamakshii Aggarwal wrote: > i am not getting any of the ways..can u expla

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
i am not getting any of the ways..can u explain? On Wed, Jul 27, 2011 at 9:06 PM, Abhinav Arora wrote: > I believe the method written is incorrect, it didnt work for me > i guess this is the right way...worked for me: > > int **p; > p=malloc(3*sizeof(int *)); > > -- > You received this messag

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Abhinav Arora
I believe the method written is incorrect, it didnt work for me i guess this is the right way...worked for me: int **p; p=malloc(3*sizeof(int *)); -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this discussion on the web visit

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread ramya reddy
int * [3] represents that 'a' is a integer pointer array of size 3. -- Regards Ramya * * *Try to learn something about everything and everything about something* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send e

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Ankur Khurana
what do you exactly mean by (int *[3]) ? On Wed, Jul 27, 2011 at 6:27 PM, ramya reddy wrote: > > int *a[3]; > a= (int *[3]) malloc( 3*sizeof(*a)); > > Regards > Ramya > -- > *Try to learn something about everything and everything about something* > > -- > You received this message because you a

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread ramya reddy
int *a[3]; a= (int *[3]) malloc( 3*sizeof(*a)); Regards Ramya -- *Try to learn something about everything and everything about something* -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googleg

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
one more question. how to dynamically allocate memory for int *a[3]; ? On Wed, Jul 27, 2011 at 5:57 PM, Kamakshii Aggarwal wrote: > thanks ankit and ramya..:) > > > On Wed, Jul 27, 2011 at 5:42 PM, Ankit wrote: > >> p is a pointer to an array of 4 ints. >> sizeof(p) gives the size of the pointer

Re: [algogeeks] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
thanks ankit and ramya..:) On Wed, Jul 27, 2011 at 5:42 PM, Ankit wrote: > p is a pointer to an array of 4 ints. > sizeof(p) gives the size of the pointer which is an int and sizeof(*p) > gives the size of the array it points (4*4=16) > > On Jul 27, 3:44 pm, Kamakshii Aggarwal wrote: > > #incl

[algogeeks] Re: OUTPUT

2011-07-27 Thread Ankit
p is a pointer to an array of 4 ints. sizeof(p) gives the size of the pointer which is an int and sizeof(*p) gives the size of the array it points (4*4=16) On Jul 27, 3:44 pm, Kamakshii Aggarwal wrote: > #include > # define MAXROW 3 > #define MAXCOL 4 > > int main() > { >     int (*p)[MAXCOL]; >

[algogeeks] Re: output

2011-07-21 Thread bipin kumar
Hi! The overall logic is that u should know the actual memory location where the data is to be stored or have a reference to it,in ur case a *a1 it is just a pointer variable . and this pointer is not pointing to the location where the new object would be allocated,so it is passed just as a point

Re: [algogeeks] Re: Output

2011-07-20 Thread surender sanke
how to deal with it?? surender On Wed, Jul 20, 2011 at 9:02 PM, sunny agrawal wrote: > > http://groups.google.com/group/programming-puzzles/browse_thread/thread/4fecd0d904624a0d > > this will clarify all doubts :) > > > On Wed, Jul 20, 2011 at 8:52 PM, SAMMM wrote: > >> Yaa even if it is 8 byte

Re: [algogeeks] Re: Output

2011-07-20 Thread sunny agrawal
http://groups.google.com/group/programming-puzzles/browse_thread/thread/4fecd0d904624a0d this will clarify all doubts :) On Wed, Jul 20, 2011 at 8:52 PM, SAMMM wrote: > Yaa even if it is 8 bytes long . Compiler will treat the value 10 as 8 > bytes only . It should be able to assign it to the po

[algogeeks] Re: Output

2011-07-20 Thread SAMMM
Yaa even if it is 8 bytes long . Compiler will treat the value 10 as 8 bytes only . It should be able to assign it to the pointer of the same size (type) .. Try to free the dynamically allocated memory just before " return 0 " and tell me the result after compilation . Try this :- int main() {

Re: [algogeeks] Re: output

2011-07-12 Thread rahul
x const a1; x a2; try this. On Tue, Jul 12, 2011 at 11:11 PM, shiv narayan wrote: > cant i invoke both simultaneously?? > if i try to make two objects like > x const a; > x a; > then it gives error..can u explain plz. > > On Jul 12, 9:55 pm, Sandeep Jain wrote: > > *const* in C++ is not exactly

[algogeeks] Re: output

2011-07-12 Thread shiv narayan
cant i invoke both simultaneously?? if i try to make two objects like x const a; x a; then it gives error..can u explain plz. On Jul 12, 9:55 pm, Sandeep Jain wrote: > *const* in C++ is not exactly same as *final* in java. SO unlike java adding > the keyword const to a function does not affect ov

Re: [algogeeks] Re: output plzz

2011-06-29 Thread shady
how to print datatype of a literal in C/C++ ? On Sat, Jun 25, 2011 at 4:27 PM, L wrote: > This happens because 'd' is automatically cast into type 'size_t' > which is basically unsigned int type. > So, it compares with TOTAL_ELEMENTS. Explicitly cast it into > int, if you want it to wor

Re: [algogeeks] Re: output plzz

2011-06-29 Thread Kamakshii Aggarwal
thanks sameer. On Wed, Jun 29, 2011 at 10:19 AM, sameer.mut...@gmail.com < sameer.mut...@gmail.com> wrote: > We are getting same output because in this problem we wre typecastin > unsigned integer to a signed integer...Hence normal operation results. > > On 6/28/11, Kamakshii Aggarwal wrote: > >

Re: [algogeeks] Re: output plzz

2011-06-28 Thread sameer.mut...@gmail.com
We are getting same output because in this problem we wre typecastin unsigned integer to a signed integer...Hence normal operation results. On 6/28/11, Kamakshii Aggarwal wrote: > #include > > int main() > { > > int array[] = {23,34,12,17,204,99,16}; > int TOTAL_ELEMENTS =(sizeof(array) / sizeof(

Re: [algogeeks] Re: output plzz

2011-06-28 Thread Kamakshii Aggarwal
#include int main() { int array[] = {23,34,12,17,204,99,16}; int TOTAL_ELEMENTS =(sizeof(array) / sizeof(array[0])); int d; for(d=-1;d <= (TOTAL_ELEMENTS-2);d++) printf("%d\n",array[d+1]); return 0; } but in this case we are getting the same o/p..can u please again explain whats wrong with the a

Re: [algogeeks] Re: output plzz

2011-06-25 Thread nicks
that's grt...i didn't knew it !! On Sat, Jun 25, 2011 at 4:43 AM, Anantha Krishnan < ananthakrishnan@gmail.com> wrote: > Good. > > > On Sat, Jun 25, 2011 at 4:47 PM, RITESH SRIVASTAV < > riteshkumar...@gmail.com> wrote: > >> sizeof returns size_t values and size_t is "typedef unsigned int >>

Re: [algogeeks] Re: output plzz

2011-06-25 Thread Anantha Krishnan
Good. On Sat, Jun 25, 2011 at 4:47 PM, RITESH SRIVASTAV wrote: > sizeof returns size_t values and size_t is "typedef unsigned int > size_t;" > but when you compare it with -1(int) ,d=-1 is converted to unsigned > int > which becomes very large (INT_MAX) > and d (INT_MAX) > 7 so the loop is never

[algogeeks] Re: output plzz

2011-06-25 Thread RITESH SRIVASTAV
sizeof returns size_t values and size_t is "typedef unsigned int size_t;" but when you compare it with -1(int) ,d=-1 is converted to unsigned int which becomes very large (INT_MAX) and d (INT_MAX) > 7 so the loop is never executed. On Jun 25, 3:23 pm, harshit pahuja wrote: > #include > #define TO

[algogeeks] Re: output plzz

2011-06-25 Thread L
This happens because 'd' is automatically cast into type 'size_t' which is basically unsigned int type. So, it compares with TOTAL_ELEMENTS. Explicitly cast it into int, if you want it to work! On Jun 25, 3:23 pm, harshit pahuja wrote: > #include > #define TOTAL_ELEMENTS (sizeof(array) /

Re: [algogeeks] Re: output....

2011-06-20 Thread Shachindra A C
change 1st line to i = 3 and execute. It will print 9. If i = 4, then the default case gets executed and then goes to case 3, then i's val will be 9. Later, it comes out of the switch block and prints the val as 9. On Mon, Jun 20, 2011 at 4:10 PM, oppilas . wrote: > Nick, > I had just tested the c

Re: [algogeeks] Re: output....

2011-06-20 Thread oppilas .
Nick, I had just tested the code for confirming my doubt whether break statement takes the program counter outside of the first "loop" or not. int i = 4; switch (i) { default: ; case 3: i += 5; if ( i == 8){ i++;

Re: [algogeeks] Re: output....

2011-06-20 Thread nicks
what's the problem...when t=6 the break statement gets executed and the control comes out of the for loop.. hence prints 6.. On Mon, Jun 20, 2011 at 12:05 AM, Oppilas wrote: > Sanjay, > Whenever we encounter a break statement does not it means to take the > program counter outside of the cu

[algogeeks] Re: output....

2011-06-20 Thread Oppilas
Sanjay, Whenever we encounter a break statement does not it means to take the program counter outside of the current loop. I am confused a little bit. Someone please clarify. See the following program #include #include int main(){ int t=4; for(int i=0;i<5;i++){ if(1){ if(t==6)

[algogeeks] Re: output for optimal binary search tree

2010-10-13 Thread Shiyam code_for_life
Can you be clear here? There is no difference in printing a binary tree whether its optimized or not! Or am I missing something here? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.