[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 of following c program : 

 #includestdio.h
  main()
  {
  int a[] ={ 1,2,3,4,5,6,7};
  char c[] = {'a','x','h','o','k'};
  //printf(%u   %u\n, a[3], a[0]);  line 6
  printf(%d %d %d %d \n, (a[3]-a[0]));
  }

 If line 6 is commented, output : 

 3 1562814827 1869117537 0 

 Confusion : why is there 4 output?   (a[3]-a[0]) should give only one.

 if line 6 is not commented, output : 
  
 1554221244   1554221232
 3 1554221232 1309214001 64



 Can anybody please explain why/how these outputs are coming?

 Thanks,
 Pawan. 


-- 
You received this message because you are subscribed to the Google Groups 
Algorithm Geeks group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to algogeeks+unsubscr...@googlegroups.com.


Re: [algogeeks] Re: Output

2012-11-25 Thread rajesh pandey
thanks
@Dave n Rushiraj

I think I have got the solution .  15-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...0 = 000...100 =  64
 for 127-- 000... 111  111...0 = 000...110 = 111

I hope this is correct .
Please correct me if I am wrong.

Thanks,
Rajesh


On Sat, Nov 24, 2012 at 8:36 PM, Dave dave_and_da...@juno.com wrote:

 @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
 = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
 (=3*32 + 31) goes to 3*32 = 96.

 Dave

 On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:

 void dosomething(int num)
 {
 int mask=~(15-1);
 int res=nummask;
 printf(%d,res);
 }
 int main()
 {
 dosomething(56);
 dosomething(64);
 dosomething(127);
 return 0;
 }

 please explain  the logic behind the output.

 Thanks,
 Rajesh

  --




-- 




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 16) is zero which is
present in 56 and 127 but not in 64
so 64 remains the same but 56 and 127 got reduced by 16.


On Sat, Nov 24, 2012 at 8:36 PM, Dave dave_and_da...@juno.com wrote:

 @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
 = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
 (=3*32 + 31) goes to 3*32 = 96.

 Dave

 On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:

 void dosomething(int num)
 {
 int mask=~(15-1);
 int res=nummask;
  printf(%d,res);
 }
 int main()
 {
 dosomething(56);
  dosomething(64);
 dosomething(127);
 return 0;
 }

 please explain  the logic behind the output.

 Thanks,
 Rajesh

  --






-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 




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 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 16) is zero which is
 present in 56 and 127 but not in 64
 so 64 remains the same but 56 and 127 got reduced by 16.


 On Sat, Nov 24, 2012 at 8:36 PM, Dave dave_and_da...@juno.com wrote:

 @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
 = (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127
 (=3*32 + 31) goes to 3*32 = 96.

 Dave

 On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:

 void dosomething(int num)
 {
 int mask=~(15-1);
 int res=nummask;
  printf(%d,res);
 }
 int main()
 {
 dosomething(56);
  dosomething(64);
 dosomething(127);
 return 0;
 }

 please explain  the logic behind the output.

 Thanks,
 Rajesh

  --






 --
 Thanks and Regards:
 Rahul Kumar Patle
 M.Tech, School of Information Technology
 Indian Institute of Technology, Kharagpur-721302, 
 Indiahttp://www.iitkgp.ac.in/
 Mobile No: +91-8798049298, +91-9424738542
 Alternate Email: rahulkumarpa...@hotmail.com
 [image: 
 Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
 [image: Twitter] https://twitter.com/rahulkumarpatle
 https://www.facebook.com/rkpatle




-- 
Thanks and Regards:
Rahul Kumar Patle
M.Tech, School of Information Technology
Indian Institute of Technology, Kharagpur-721302,
Indiahttp://www.iitkgp.ac.in/
Mobile No: +91-8798049298, +91-9424738542
Alternate Email: rahulkumarpa...@hotmail.com
[image: Linkedin]http://www.linkedin.com/profile/view?id=106245716trk=tab_pro
[image: Twitter] https://twitter.com/rahulkumarpatle
https://www.facebook.com/rkpatle

-- 




[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 
= (1*32 + 24) goes to 1*32 = 32, 64 (=2*32 + 0) stays at 2*32 = 64, and 127 
(=3*32 + 31) goes to 3*32 = 96.
 
Dave

On Saturday, November 24, 2012 2:45:24 AM UTC-6, rajesh pandey wrote:

 void dosomething(int num)
 {
 int mask=~(15-1);
 int res=nummask;
 printf(%d,res);
 }
 int main()
 {
 dosomething(56);
 dosomething(64);
 dosomething(127);
 return 0;
 }

 please explain  the logic behind the output.

 Thanks,
 Rajesh  


-- 




[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;
else
{

while(*p2++=*p1++);

printf(%s\n,save);
}

for the second qs o/p = 25 
cz post incr means first use den incr  thererfore 5*5 



-- 
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/-/lOll02QN_pwJ.
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] 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 || is
a sequence point.

On Wed, Jul 25, 2012 at 8:42 PM, deepikaanand swinyanand...@gmail.com wrote:
 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;
 else
 {

 while(*p2++=*p1++);

 printf(%s\n,save);
 }

 for the second qs o/p = 25
 cz post incr means first use den incr  thererfore 5*5

 --
 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/-/lOll02QN_pwJ.

 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.



-- 
Vindhya Chhabra

-- 
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] 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=5;
 printf(%d,i++ * i++);
 o/p and also tell the reason?


-- 
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/-/_rwcRL6t5ywJ.
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] 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 wrote:

 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;
 else
 {
 
 while(*p2++=*p1++);

 printf(%s\n,save);
 }

 for the second qs o/p = 25 
 cz post incr means first use den incr  thererfore 5*5 


On Wednesday, 25 July 2012 20:42:56 UTC+5:30, deepikaanand wrote:

 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;
 else
 {
 
 while(*p2++=*p1++);

 printf(%s\n,save);
 }

 for the second qs o/p = 25 
 cz post incr means first use den incr  thererfore 5*5 



-- 
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/-/fNnV9Hvd4bkJ.
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] 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 not error) ?   

ahh..ther's sumthng wrong with my compiler .. wen am running it online it's 
givng me the correct answ. 

 On Wednesday, 25 July 2012 20:42:56 UTC+5:30, deepikaanand wrote:

 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;
 else
 {
 
 while(*p2++=*p1++);

 printf(%s\n,save);
 }

 for the second qs o/p = 25 
 cz post incr means first use den incr  thererfore 5*5 


 On Wednesday, 25 July 2012 20:42:56 UTC+5:30, deepikaanand wrote:

 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;
 else
 {
 
 while(*p2++=*p1++);

 printf(%s\n,save);
 }

 for the second qs o/p = 25 
 cz post incr means first use den incr  thererfore 5*5 



-- 
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/-/xmObT3iqWaQJ.
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] 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 group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/TOSg6xbES24J.
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] 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 on compiler 




-- 
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/-/u5wkXT6ZDHIJ.
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] 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 here as it is coping the
content of one pointer to other as well as moving itself forward. So What
happened when While exits, is p1 points to NULL and is copied successfully
to p1 but due to post incrementation of p1 and p2 both are momentary lost
and wen't beyond the '\0' character.. So when U print it it goes printing
all the rest of 20 character bytes losing it front values. hope U guys have
u r clear picture now.

2 Is compiler dependent but can be kinda predictable.
 Reason:-
1 STL says the two point rule as someone stated above. Coz they
feared if this rule does not followed that big chaos might happen but here
its simple and kinda predictable.
2 Anyone who have worked or know a bit of Embedded can easily tell
how the hardware operated on this equation.

Prem


On Wed, Jul 25, 2012 at 9:10 PM, deepikaanand swinyanand...@gmail.comwrote:

 @ 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 group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/algogeeks/-/TOSg6xbES24J.

 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] 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 me the correct answer and for the second qs  has no 
 absolute answer it depends on compiler 



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 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 group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/algogeeks/-/fsXZTCbPuIgJ.
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] 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.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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 swinyanand...@gmail.comwrote:

 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.
 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] 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 options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.



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 kumarvive...@gmail.com wrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
Ayush

-- 
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] Re: Output?? Why??

2011-08-17 Thread payal gupta
i modified the code a lil bit
#includestdio.h
#includeconio.h
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 ayush21011...@gmail.comwrote:

 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 kumarvive...@gmail.com wrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

  --
 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] 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 gpt.pa...@gmail.com wrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 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 ayush21011...@gmail.comwrote:

 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 kumarvive...@gmail.com wrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

  --
 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.




-- 
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] 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 aditi.garg.6...@gmail.comwrote:

 @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 gpt.pa...@gmail.com wrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 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 ayush21011...@gmail.comwrote:

 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 kumarvive...@gmail.com wrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

 --
 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.




 --
 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.




-- 
Regards

Vartika Aggarwal
Undergraduate Student
IT Department
NSIT, Dwarka

-- 
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] 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 vartika.aggarwa...@gmail.comwrote:

 @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 aditi.garg.6...@gmail.comwrote:

 @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 gpt.pa...@gmail.com wrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 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 
 ayush21011...@gmail.comwrote:

 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 kumarvive...@gmail.com wrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

 --
 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.




 --
 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.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

  --
 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] 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 dip10c...@gmail.com 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 
 vartika.aggarwa...@gmail.comwrote:

  @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 aditi.garg.6...@gmail.comwrote:

 @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 gpt.pa...@gmail.comwrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 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 
 ayush21011...@gmail.comwrote:

 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 kumarvive...@gmail.comwrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

 --
 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.




 --
 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.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

 --
   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.




-- 
Regards

Vartika Aggarwal
Undergraduate Student
IT Department
NSIT, Dwarka

-- 
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] 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 vartika.aggarwa...@gmail.comwrote:

 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 dip10c...@gmail.comwrote:

 Thats new..
 Its not working in C++, where as in C it works like a charm.

   On 18 August 2011 08:57, vartika aggarwal vartika.aggarwa...@gmail.com
  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 
 aditi.garg.6...@gmail.comwrote:

 @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 gpt.pa...@gmail.comwrote:

 i modified the code a lil bit
 #includestdio.h
 #includeconio.h
 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 ayush21011...@gmail.com
  wrote:

 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 kumarvive...@gmail.comwrote:

 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 options, visit this group at
 http://groups.google.com/group/algogeeks?hl=en.




 --
 Ayush

 --
 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.




 --
 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.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

 --
   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.




 --
 Regards

 Vartika Aggarwal
 Undergraduate Student
 IT Department
 NSIT, Dwarka

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

Re: [algogeeks] Re: output???

2011-08-06 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 why a==.5? works but not c==.7?


On Sat, Aug 6, 2011 at 10:40 AM, saurabh singh saurab...@gmail.com wrote:

 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
 http://ideone.com/y1AhuIts equal bcoz the higher bits will be 0 for both
 double and float.
 similar result occurs for 0.25 0.75 0.10 etc,.

 On Sat, Aug 6, 2011 at 10:26 AM, sagar pareek sagarpar...@gmail.comwrote:

 @saurabh

 what? i didnt get you


 On Sat, Aug 6, 2011 at 10:22 AM, saurabh singh saurab...@gmail.comwrote:

 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 sagarpar...@gmail.comwrote:

 see what piyush posted


 On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain shashan...@gmail.comwrote:

 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 sagarpar...@gmail.comwrote:

 yup exactly

 On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.comwrote:

 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=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.


  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT 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] 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  a;

-- 
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] Re: output???

2011-08-05 Thread sagar pareek
@vikas
first read what i wrote

On Sat, Aug 6, 2011 at 12:59 AM, vikash vikash.ckiiit...@gmail.com 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 two float is typecasted into double and so the ramaining
 bits are padded with 0 so 0.7  a;

 --
 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
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT 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] 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=Staticd1=tutorialsd2=integersReals


-- 
*Regards,*
*Piyush Kapoor,*
*2nd year,CSE
IT-BHU*

-- 
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] Re: output???

2011-08-05 Thread sagar pareek
yup exactly

On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.com 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/tc?module=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT 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] 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 sagarpar...@gmail.com wrote:

 yup exactly

 On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.com 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/tc?module=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.


-- 
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] Re: output???

2011-08-05 Thread sagar pareek
see what piyush posted

On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain shashan...@gmail.com 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 sagarpar...@gmail.comwrote:

 yup exactly

 On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.comwrote:

 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=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.


  --
 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
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT 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] 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 sagarpar...@gmail.com wrote:

 see what piyush posted


 On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain shashan...@gmail.comwrote:

 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 sagarpar...@gmail.comwrote:

 yup exactly

 On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.comwrote:

 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=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.


  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.




-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT 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] 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 saurab...@gmail.com 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 sagarpar...@gmail.comwrote:

 see what piyush posted


 On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain shashan...@gmail.comwrote:

 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 sagarpar...@gmail.comwrote:

 yup exactly

 On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.comwrote:

 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=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.


  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




-- 
**Regards
SAGAR PAREEK
COMPUTER SCIENCE AND ENGINEERING
NIT 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] 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
http://ideone.com/y1AhuIts equal bcoz the higher bits will be 0 for both
double and float.
similar result occurs for 0.25 0.75 0.10 etc,.
On Sat, Aug 6, 2011 at 10:26 AM, sagar pareek sagarpar...@gmail.com wrote:

 @saurabh

 what? i didnt get you


 On Sat, Aug 6, 2011 at 10:22 AM, saurabh singh saurab...@gmail.comwrote:

 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 sagarpar...@gmail.comwrote:

 see what piyush posted


 On Sat, Aug 6, 2011 at 4:35 AM, Shashank Jain shashan...@gmail.comwrote:

 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 sagarpar...@gmail.comwrote:

 yup exactly

 On Sat, Aug 6, 2011 at 1:51 AM, Piyush Kapoor pkjee2...@gmail.comwrote:

 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=Staticd1=tutorialsd2=integersReals


 --
 *Regards,*
 *Piyush Kapoor,*
 *2nd year,CSE
 IT-BHU*

  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.


  --
 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
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.




 --
 Saurabh Singh
 B.Tech (Computer Science)
 MNNIT 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.




 --
 **Regards
 SAGAR PAREEK
 COMPUTER SCIENCE AND ENGINEERING
 NIT 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.




-- 
Saurabh Singh
B.Tech (Computer Science)
MNNIT 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.



[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 kamakshi...@gmail.com wrote:
 #includestdio.h
 # define MAXROW 3
 #define MAXCOL 4

 int main()
 {
     int (*p)[MAXCOL];
     p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
     printf(%d %d,sizeof(p),sizeof(*p));

  system(pause);

   return 0;

 }

 THE O/P IS 4 16.
 I am not getting the reason.plss help

-- 
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] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
thanks ankit and ramya..:)


On Wed, Jul 27, 2011 at 5:42 PM, Ankit ankitchaudhar...@gmail.com 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 kamakshi...@gmail.com wrote:
  #includestdio.h
  # define MAXROW 3
  #define MAXCOL 4
 
  int main()
  {
  int (*p)[MAXCOL];
  p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
  printf(%d %d,sizeof(p),sizeof(*p));
 
   system(pause);
 
return 0;
 
  }
 
  THE O/P IS 4 16.
  I am not getting the reason.plss help

 --
 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,
Kamakshi
kamakshi...@gmail.com

-- 
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] 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
kamakshi...@gmail.comwrote:

 thanks ankit and ramya..:)


 On Wed, Jul 27, 2011 at 5:42 PM, Ankit ankitchaudhar...@gmail.com 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 kamakshi...@gmail.com wrote:
  #includestdio.h
  # define MAXROW 3
  #define MAXCOL 4
 
  int main()
  {
  int (*p)[MAXCOL];
  p=(int(*)[MAXCOL])malloc(MAXROW*sizeof(*p));
  printf(%d %d,sizeof(p),sizeof(*p));
 
   system(pause);
 
return 0;
 
  }
 
  THE O/P IS 4 16.
  I am not getting the reason.plss help

 --
 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,
 Kamakshi
 kamakshi...@gmail.com




-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
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] 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@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] 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 rmy.re...@gmail.com 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 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.




-- 
Ankur Khurana
Computer Science
Netaji Subhas Institute Of Technology
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] 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 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] 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 
https://groups.google.com/d/msg/algogeeks/-/ATGevOaqMbUJ.
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] 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 abhinavdgr8b...@gmail.comwrote:

 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
 https://groups.google.com/d/msg/algogeeks/-/ATGevOaqMbUJ.

 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,
Kamakshi
kamakshi...@gmail.com

-- 
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] 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 kamakshi...@gmail.com wrote:
 i am not getting any of the ways..can u explain?

 On Wed, Jul 27, 2011 at 9:06 PM, Abhinav Arora 
 abhinavdgr8b...@gmail.comwrote:





  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
 https://groups.google.com/d/msg/algogeeks/-/ATGevOaqMbUJ.

  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,
 Kamakshi
 kamakshi...@gmail.com

-- 
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] 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 for an array of integer pointers the result of malloc 
should point to the first element of the dynamically allocated array. The 
elements of the array are pointers hence the memory allocated will be saved 
in a pointer that will correspond to the pointer to the first element. Since 
the elements are pointers so the result of malloc will be saved to a pointer 
to a pointer.

My sample program which i compiled in Dev C++ is as follows :


#includestdio.h
#includeconio.h
main()
{
  int a,b,c;
  int **p;
  p=malloc(3*sizeof(int *));
  a=b=c=1;
  p[0]=a;
  p[1]=b;
  p[2]=c;
  printf(%d %d %d,*p[0],*p[1],*p[2]);
  getch();
  }

-- 
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/-/ScQJutsiThgJ.
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] Re: OUTPUT

2011-07-27 Thread Kamakshii Aggarwal
@abhinav:thanks.:)

On Wed, Jul 27, 2011 at 9:23 PM, Abhinav Arora abhinavdgr8b...@gmail.comwrote:

 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 for an array of integer pointers the result of malloc
 should point to the first element of the dynamically allocated array. The
 elements of the array are pointers hence the memory allocated will be saved
 in a pointer that will correspond to the pointer to the first element. Since
 the elements are pointers so the result of malloc will be saved to a pointer
 to a pointer.

 My sample program which i compiled in Dev C++ is as follows :


 #includestdio.h
 #includeconio.h
 main()
 {
   int a,b,c;
   int **p;
   p=malloc(3*sizeof(int *));
   a=b=c=1;
   p[0]=a;
   p[1]=b;
   p[2]=c;
   printf(%d %d %d,*p[0],*p[1],*p[2]);
   getch();
   }

 --
 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/-/ScQJutsiThgJ.

 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,
Kamakshi
kamakshi...@gmail.com

-- 
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] 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 pointer variable to the function
f(a *b)
where this variable is overwritten by the ,actual address where the
object is being allocated through new a().

and in ur main ,the value of the pointer variable is still not
known,it just random ,that's why u are getting output as something
garbage.

passing the address of the pointer is allready being discussed,
but in other method u can just pass the address of the new object to
the calling function that will tell ur main(),that what is the actual
location of the object;and this time
it is not garbage.

a*  f(a * b)
{
 b = new a();
 b-set(5);
return b;
}


int main()
{
 a *a1;
 a1=f(a1);
 coutx = a1-get();
return 0;


}




On Jul 21, 5:10 pm, Saurabh saurabh24...@gmail.com wrote:
 Can any one explain why the following program not giving the correct output.

 #include iostream
 using namespace std;
 class a
 {
        int x;

        public:
                void set(int y)
                {
                                x=y;
                }
                int get()
                {
                       return x;
                }

 };

 void f(a * b)
 {
      b = new a();
      b-set(5);}

 int main()
 {
      a *a1;
      f(a1);
      coutx = a1-get();
     return 0;

 }

 --
 Regards
 Saurabh

-- 
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] 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()
  {
  int* p;


  p = (int*)malloc(sizeof(int));


  *p = 10;

   free(p); /* Try This */

 return 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] 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 somnath.nit...@gmail.com 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 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()
  {
  int* p;


  p = (int*)malloc(sizeof(int));


  *p = 10;

free(p); /* Try This */

 return 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.




-- 
Sunny Aggrawal
B-Tech IV year,CSI
Indian Institute Of Technology,Roorkee

-- 
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] 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 sunny816.i...@gmail.comwrote:


 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 somnath.nit...@gmail.com 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 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()
  {
  int* p;


  p = (int*)malloc(sizeof(int));


  *p = 10;

free(p); /* Try This */

 return 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.




 --
 Sunny Aggrawal
 B-Tech IV year,CSI
 Indian Institute Of Technology,Roorkee

  --
 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] 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 sandeep6...@gmail.com 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 overriding.
 Infact, adding in C++ const functions == that they will not modify any
 member of the class.
 non-const functions cannot be invoked by const objects.

 Try making object 'a' as const i.e.
 const x a;
 and then invoke f(), it should invoke the correct version.

 Note that C++ allows function overloading based on const-ness.
 Refer (Const function 
 section)http://www.cprogramming.com/tutorial/const_correctness.html
 Also, subscript operators generally come in pairs, 
 Referhttp://www.parashift.com/c++-faq-lite/operator-overloading.html#faq-1...http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.12

 Regards,
 Sandeep Jain

 On Tue, Jul 12, 2011 at 10:09 PM, dheeraj tyagi dheeraj2...@gmail.comwrote:







  const means that it cannot be overloaded..i think due to that this is
  happening.

  On Tue, Jul 12, 2011 at 9:26 PM, segfault pawan1991ya...@gmail.comwrote:

  #includeiostream
  using namespace std;
  class x{
  public:
  x() {}

  int  func() const{
  coutit is const function\n;
  }

  int func() {
  coutit is simple functin\n;
  }

  };
  int main()
  {
  x a;
  a.func();
  return 0;
  }

  why cann't it take const function?
  explain it

  --
  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.

  --
  With regards
  Dheeraj Tyagi
  8197218001

   --
  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] 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 narayan.shiv...@gmail.comwrote:

 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 sandeep6...@gmail.com 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 overriding.
  Infact, adding in C++ const functions == that they will not modify any
  member of the class.
  non-const functions cannot be invoked by const objects.
 
  Try making object 'a' as const i.e.
  const x a;
  and then invoke f(), it should invoke the correct version.
 
  Note that C++ allows function overloading based on const-ness.
  Refer (Const function section)
 http://www.cprogramming.com/tutorial/const_correctness.html
  Also, subscript operators generally come in pairs, Referhttp://
 www.parashift.com/c++-faq-lite/operator-overloading.html#faq-1...http://www.parashift.com/c++-faq-lite/const-correctness.html#faq-18.12
 
  Regards,
  Sandeep Jain
 
  On Tue, Jul 12, 2011 at 10:09 PM, dheeraj tyagi dheeraj2...@gmail.com
 wrote:
 
 
 
 
 
 
 
   const means that it cannot be overloaded..i think due to that this is
   happening.
 
   On Tue, Jul 12, 2011 at 9:26 PM, segfault pawan1991ya...@gmail.com
 wrote:
 
   #includeiostream
   using namespace std;
   class x{
   public:
   x() {}
 
   int  func() const{
   coutit is const function\n;
   }
 
   int func() {
   coutit is simple functin\n;
   }
 
   };
   int main()
   {
   x a;
   a.func();
   return 0;
   }
 
   why cann't it take const function?
   explain it
 
   --
   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.
 
   --
   With regards
   Dheeraj Tyagi
   8197218001
 
--
   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] 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 kamakshi...@gmail.com wrote:
  #includestdio.h
 
  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 above question.
 
  On Sat, Jun 25, 2011 at 9:24 PM, nicks crazy.logic.k...@gmail.com
 wrote:
 
  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
  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 hpahuja.mn...@gmail.com wrote:
   #includestdio.h
   #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
   int array[] = {23,34,12,17,204,99,16};
   int main()
   {
   int d;
   for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
   printf(%d\n,array[d+1]);
   return 0;
  
   }
  
   y der is nothing in the output .
  
   -
   Regards -
   HARSHIT PAHUJA
 
  --
  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.
 
 
 
 
  --
  Regards,
  Kamakshi
  kamakshi...@gmail.com
 
  --
  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.




-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
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] 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 prnk.bhatna...@gmail.com 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 work!

 On Jun 25, 3:23 pm, harshit pahuja hpahuja.mn...@gmail.com wrote:
  #includestdio.h
  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};
  int main()
  {
  int d;
  for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
  printf(%d\n,array[d+1]);
  return 0;
 
  }
 
  y der is nothing in the output .
 
  -
  Regards -
  HARSHIT PAHUJA

 --
 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] Re: output plzz

2011-06-28 Thread Kamakshii Aggarwal
#includestdio.h

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 above question.

On Sat, Jun 25, 2011 at 9:24 PM, nicks crazy.logic.k...@gmail.com wrote:

 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
 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 hpahuja.mn...@gmail.com wrote:
  #includestdio.h
  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};
  int main()
  {
  int d;
  for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
  printf(%d\n,array[d+1]);
  return 0;
 
  }
 
  y der is nothing in the output .
 
  -
  Regards -
  HARSHIT PAHUJA

 --
 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.




-- 
Regards,
Kamakshi
kamakshi...@gmail.com

-- 
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] 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 kamakshi...@gmail.com wrote:
 #includestdio.h

 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 above question.

 On Sat, Jun 25, 2011 at 9:24 PM, nicks crazy.logic.k...@gmail.com wrote:

 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
 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 hpahuja.mn...@gmail.com wrote:
  #includestdio.h
  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};
  int main()
  {
  int d;
  for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
  printf(%d\n,array[d+1]);
  return 0;
 
  }
 
  y der is nothing in the output .
 
  -
  Regards -
  HARSHIT PAHUJA

 --
 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.




 --
 Regards,
 Kamakshi
 kamakshi...@gmail.com

 --
 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] 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 hpahuja.mn...@gmail.com wrote:
 #includestdio.h
 #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
 int array[] = {23,34,12,17,204,99,16};
 int main()
 {
 int d;
 for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
 printf(%d\n,array[d+1]);
 return 0;

 }

 y der is nothing in the output .

 -
 Regards -
 HARSHIT PAHUJA

-- 
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] 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 hpahuja.mn...@gmail.com wrote:
 #includestdio.h
 #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
 int array[] = {23,34,12,17,204,99,16};
 int main()
 {
 int d;
 for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
 printf(%d\n,array[d+1]);
 return 0;

 }

 y der is nothing in the output .

 -
 Regards -
 HARSHIT PAHUJA

-- 
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] Re: output plzz

2011-06-25 Thread Anantha Krishnan
Good.

On Sat, Jun 25, 2011 at 4:47 PM, RITESH SRIVASTAV
riteshkumar...@gmail.comwrote:

 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 hpahuja.mn...@gmail.com wrote:
  #includestdio.h
  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};
  int main()
  {
  int d;
  for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
  printf(%d\n,array[d+1]);
  return 0;
 
  }
 
  y der is nothing in the output .
 
  -
  Regards -
  HARSHIT PAHUJA

 --
 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] 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
 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 hpahuja.mn...@gmail.com wrote:
  #includestdio.h
  #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
  int array[] = {23,34,12,17,204,99,16};
  int main()
  {
  int d;
  for(d=-1;d = (TOTAL_ELEMENTS-2);d++)
  printf(%d\n,array[d+1]);
  return 0;
 
  }
 
  y der is nothing in the output .
 
  -
  Regards -
  HARSHIT PAHUJA

 --
 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.



[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
#includestdio.h
#includestdlib.h
int main(){
int t=4;
for(int i=0;i5;i++){
if(1){
  if(t==6) break;
  }
  t++;
}
   printf(%d,t);
   /* Prints 6 */
return 0;
}

~
Oll
On Jun 19, 6:05 pm, sanjay ahuja sanjayahuja.i...@gmail.com wrote:
 i=4 is default case for but there is no break statement after default
 case. There for all cases until break is encountered will be executed.
 so i += 5;  makes i=9
 i -= 4; will make i=5
 and then break
 so i is 5









 On Sun, Jun 19, 2011 at 6:29 PM, sahil sahil18...@gmail.com wrote:
  #includestdio.h
  void main()
  { int i = 4;

  switch (i)
  {

  default: ;
  case 3:
  i += 5;
  if ( i == 8)
  {
  i++;
  if (i == 9) break;
  i *= 2;
  }
  i -= 4;
  break;

  case 8:
  i += 5;
  break;
  }
  printf(i = %d\n, i);
  }

  output:

  i=5

  how..? can sme one explain...!!

  --
  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 
  athttp://groups.google.com/group/algogeeks?hl=en.

 --
 Sanjay Ahuja,
 Analyst, Financing Prime Brokerage
 Nomura Securities India Pvt. Ltd

-- 
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] 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 jatka.oppimi...@gmail.com wrote:

 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
 #includestdio.h
 #includestdlib.h
 int main(){
int t=4;
for(int i=0;i5;i++){
if(1){
  if(t==6) break;
  }
  t++;
}
   printf(%d,t);
   /* Prints 6 */
return 0;
 }

 ~
 Oll
 On Jun 19, 6:05 pm, sanjay ahuja sanjayahuja.i...@gmail.com wrote:
  i=4 is default case for but there is no break statement after default
  case. There for all cases until break is encountered will be executed.
  so i += 5;  makes i=9
  i -= 4; will make i=5
  and then break
  so i is 5
 
 
 
 
 
 
 
 
 
  On Sun, Jun 19, 2011 at 6:29 PM, sahil sahil18...@gmail.com wrote:
   #includestdio.h
   void main()
   { int i = 4;
 
   switch (i)
   {
 
   default: ;
   case 3:
   i += 5;
   if ( i == 8)
   {
   i++;
   if (i == 9) break;
   i *= 2;
   }
   i -= 4;
   break;
 
   case 8:
   i += 5;
   break;
   }
   printf(i = %d\n, i);
   }
 
   output:
 
   i=5
 
   how..? can sme one explain...!!
 
   --
   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 athttp://
 groups.google.com/group/algogeeks?hl=en.
 
  --
  Sanjay Ahuja,
  Analyst, Financing Prime Brokerage
  Nomura Securities India Pvt. Ltd

 --
 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] 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++;
 * if (i == 9) break; /* Now after executing
this break should't the program counter go to priintf statement*
*/* and print 9*
* * i *= 2;
  }
  i -= 4;
  break;

   case 8:
 i += 5;
 break;
  }
 printf(i = %d\n, i);
}

On Mon, Jun 20, 2011 at 1:30 PM, nicks crazy.logic.k...@gmail.com wrote:

 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 jatka.oppimi...@gmail.comwrote:

 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
 #includestdio.h
 #includestdlib.h
 int main(){
int t=4;
for(int i=0;i5;i++){
if(1){
  if(t==6) break;
  }
  t++;
}
   printf(%d,t);
   /* Prints 6 */
return 0;
 }

 ~
 Oll
 On Jun 19, 6:05 pm, sanjay ahuja sanjayahuja.i...@gmail.com wrote:
  i=4 is default case for but there is no break statement after default
  case. There for all cases until break is encountered will be executed.
  so i += 5;  makes i=9
  i -= 4; will make i=5
  and then break
  so i is 5
 
 
 
 
 
 
 
 
 
  On Sun, Jun 19, 2011 at 6:29 PM, sahil sahil18...@gmail.com wrote:
   #includestdio.h
   void main()
   { int i = 4;
 
   switch (i)
   {
 
   default: ;
   case 3:
   i += 5;
   if ( i == 8)
   {
   i++;
   if (i == 9) break;
   i *= 2;
   }
   i -= 4;
   break;
 
   case 8:
   i += 5;
   break;
   }
   printf(i = %d\n, i);
   }
 
   output:
 
   i=5
 
   how..? can sme one explain...!!
 
   --
   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 athttp://
 groups.google.com/group/algogeeks?hl=en.
 
  --
  Sanjay Ahuja,
  Analyst, Financing Prime Brokerage
  Nomura Securities India Pvt. Ltd

 --
 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] 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 . jatka.oppimi...@gmail.comwrote:

 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++;
  * if (i == 9) break; /* Now after executing
 this break should't the program counter go to priintf statement*
 */* and print 9*
 * * i *= 2;
   }
   i -= 4;
   break;

case 8:
  i += 5;
  break;
   }
  printf(i = %d\n, i);
 }

 On Mon, Jun 20, 2011 at 1:30 PM, nicks crazy.logic.k...@gmail.com wrote:

 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 jatka.oppimi...@gmail.comwrote:

 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
 #includestdio.h
 #includestdlib.h
 int main(){
int t=4;
for(int i=0;i5;i++){
if(1){
  if(t==6) break;
  }
  t++;
}
   printf(%d,t);
   /* Prints 6 */
return 0;
 }

 ~
 Oll
 On Jun 19, 6:05 pm, sanjay ahuja sanjayahuja.i...@gmail.com wrote:
  i=4 is default case for but there is no break statement after default
  case. There for all cases until break is encountered will be executed.
  so i += 5;  makes i=9
  i -= 4; will make i=5
  and then break
  so i is 5
 
 
 
 
 
 
 
 
 
  On Sun, Jun 19, 2011 at 6:29 PM, sahil sahil18...@gmail.com wrote:
   #includestdio.h
   void main()
   { int i = 4;
 
   switch (i)
   {
 
   default: ;
   case 3:
   i += 5;
   if ( i == 8)
   {
   i++;
   if (i == 9) break;
   i *= 2;
   }
   i -= 4;
   break;
 
   case 8:
   i += 5;
   break;
   }
   printf(i = %d\n, i);
   }
 
   output:
 
   i=5
 
   how..? can sme one explain...!!
 
   --
   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 athttp://
 groups.google.com/group/algogeeks?hl=en.
 
  --
  Sanjay Ahuja,
  Analyst, Financing Prime Brokerage
  Nomura Securities India Pvt. Ltd

 --
 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.




-- 
Regards,
Shachindra A C

-- 
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] 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.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.