[algogeeks] output help

2011-08-09 Thread Rohit Srivastava
#includestdio.h #includeconio.h int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit={1,2,2}; printf(%d %d %d\n,bit.bit1,bit.bit3,bit.bit4); getche(); return 0; } the above code gives output : -1 2 2 any idea why??? -- You

Re: [algogeeks] output help

2011-08-09 Thread aditi garg
I think it is because bit1 is only 1 bit fwide and whn u initialize it to 1,since MSB is 1 it treats it as a negative integer...Plz correct me if i am wrong... On Tue, Aug 9, 2011 at 12:24 PM, Rohit Srivastava access2ro...@gmail.comwrote: #includestdio.h #includeconio.h int main() {

Re: [algogeeks] output help

2011-08-09 Thread sanjay ahuja
Int bit3:4 will be read as lower order 4 bits of bit3 and this will be treated as int (signed). Thus lower order bit of bit3 which is 2, are 0010 which is 2 try with 1) int bit3:2, output will be -2 2) unsigned int bit3:2, output will be 2. I hope it is cleared now On 8/9/11, Rohit Srivastava

Re: [algogeeks] output help

2011-08-09 Thread Rohit Srivastava
hey guys thanks got it!! On Tue, Aug 9, 2011 at 12:49 PM, sanjay ahuja sanjayahuja.i...@gmail.comwrote: Int bit3:4 will be read as lower order 4 bits of bit3 and this will be treated as int (signed). Thus lower order bit of bit3 which is 2, are 0010 which is 2 try with 1) int bit3:2,

Re: [algogeeks] output help

2011-08-09 Thread dinesh bansal
On a little-endian machine, bit structure will be represented as: 0x00 00 00 45 which is bit.bit4 = 0010 (2 in decimal) bit.bit3 = 0010 (2 in decimal) bit.bit1 = 1 (1 in decimal) since bit.bit1 exists at the rightmost position, while displaying data as integer, compiler just repeats the same

Re: [algogeeks] output help

2011-08-09 Thread SANDEEP CHUGH
i dnt get it.. any better explanation.. On Tue, Aug 9, 2011 at 1:13 PM, dinesh bansal bansal...@gmail.com wrote: On a little-endian machine, bit structure will be represented as: 0x00 00 00 45 which is bit.bit4 = 0010 (2 in decimal) bit.bit3 = 0010 (2 in decimal) bit.bit1 = 1 (1 in

[algogeeks] output help

2011-08-07 Thread Kamakshii Aggarwal
#includestdio.h int main() { typedef static int *i; static int j; i a = j; printf(%d, *a); getchar(); return 0; } what is the error in the code? -- Regards, Kamakshi kamakshi...@gmail.com -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] output help

2011-08-07 Thread Amol Sharma
using typedef u define the static keyword as int and the statement static int j thus becomes int int j hence the compiler gives the error multiple storage class in declaration specifiers -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Mon, Aug 8, 2011

Re: [algogeeks] output help

2011-08-07 Thread aseem garg
typedef doesn't declare an instance of a variable, it declares a type (type alias actually), static is a qualifier you apply to an instance, not a type, so you can use static when you use the type, but not when you define the type. Aseem On Mon, Aug 8, 2011 at 12:29 AM, Kamakshii Aggarwal

Re: [algogeeks] output help

2011-08-07 Thread Kamakshii Aggarwal
got it...thanks On Mon, Aug 8, 2011 at 12:39 AM, aseem garg ase.as...@gmail.com wrote: typedef doesn't declare an instance of a variable, it declares a type (type alias actually), static is a qualifier you apply to an instance, not a type, so you can use static when you use the type, but

[algogeeks] Output Help.

2011-07-30 Thread aseem garg
int b=2;b=b++; b=??? Plz explain.. Aseem -- 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.

Re: [algogeeks] Output Help.

2011-07-30 Thread Kamakshii Aggarwal
3.it is same as b=b+1; On Sun, Jul 31, 2011 at 1:32 AM, aseem garg ase.as...@gmail.com wrote: int b=2;b=b++; b=??? Plz explain.. Aseem -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Output Help.

2011-07-30 Thread aseem garg
@Kamakshi: Run karke dekh leti pehle. :-/ Aseem On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: 3.it is same as b=b+1; On Sun, Jul 31, 2011 at 1:32 AM, aseem garg ase.as...@gmail.com wrote: int b=2;b=b++; b=??? Plz explain.. Aseem -- You received

Re: [algogeeks] Output Help.

2011-07-30 Thread aditi garg
it would be undefined... On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: 3.it is same as b=b+1; On Sun, Jul 31, 2011 at 1:32 AM, aseem garg ase.as...@gmail.com wrote: int b=2;b=b++; b=??? Plz explain.. Aseem -- You received this message because you

Re: [algogeeks] Output Help.

2011-07-30 Thread Kamakshii Aggarwal
oh sorry,mane galat pad lia..mane sirf b++ dekha... it is compiler dependent.value of b is changing twice b/w two serial points On Sun, Jul 31, 2011 at 1:37 AM, aseem garg ase.as...@gmail.com wrote: @Kamakshi: Run karke dekh leti pehle. :-/ Aseem On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii

Re: [algogeeks] Output Help.

2011-07-30 Thread aseem garg
@Aditi: Run karke dekh leti pehle. :-/ Aseem On Sun, Jul 31, 2011 at 1:38 AM, aditi garg aditi.garg.6...@gmail.comwrote: it would be undefined... On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: 3.it is same as b=b+1; On Sun, Jul 31, 2011 at 1:32 AM,

Re: [algogeeks] Output Help.

2011-07-30 Thread vaibhav shukla
concept of sequence points.search wiki On Sun, Jul 31, 2011 at 1:38 AM, aditi garg aditi.garg.6...@gmail.comwrote: it would be undefined... On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: 3.it is same as b=b+1; On Sun, Jul 31, 2011 at 1:32 AM, aseem

Re: [algogeeks] Output Help.

2011-07-30 Thread Amol Sharma
@aseem output is 3 only...check it once again http://ideone.com/mWGc5 -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at 1:37 AM, aseem garg ase.as...@gmail.com wrote: @Kamakshi: Run karke dekh leti pehle. :-/ Aseem On Sun,

Re: [algogeeks] Output Help.

2011-07-30 Thread vidushi
@aseem its 3 different on yours ? On Sun, Jul 31, 2011 at 1:37 AM, aseem garg ase.as...@gmail.com wrote: @Kamakshi: Run karke dekh leti pehle. :-/ Aseem On Sun, Jul 31, 2011 at 1:34 AM, Kamakshii Aggarwal kamakshi...@gmail.com wrote: 3.it is same as b=b+1; On Sun, Jul 31, 2011 at

Re: [algogeeks] Output Help.

2011-07-30 Thread Neeraj Gupta
Yes, it's UB. For such ques, try to run it on ideone. It will give a warning if any operation is not standard. http://ideone.com/bJBGl http://ideone.com/bJBGl On Sun, Jul 31, 2011 at 1:38 AM, aditi garg aditi.garg.6...@gmail.comwrote: it would be undefined... On Sun, Jul 31, 2011 at 1:34

Re: [algogeeks] Output Help.

2011-07-30 Thread aseem garg
I am getting 2. . Aseem On Sun, Jul 31, 2011 at 1:41 AM, Neeraj Gupta neeraj.gupta...@gmail.comwrote: Yes, it's UB. For such ques, try to run it on ideone. It will give a warning if any operation is not standard. http://ideone.com/bJBGl http://ideone.com/bJBGl On Sun, Jul 31, 2011 at

Re: [algogeeks] Output Help.

2011-07-30 Thread aseem garg
On Dev CPP. Aseem On Sun, Jul 31, 2011 at 1:42 AM, aseem garg ase.as...@gmail.com wrote: I am getting 2. . Aseem On Sun, Jul 31, 2011 at 1:41 AM, Neeraj Gupta neeraj.gupta...@gmail.comwrote: Yes, it's UB. For such ques, try to run it on ideone. It will give a warning if any

Re: [algogeeks] Output Help.

2011-07-30 Thread Amol Sharma
yup it is undefined and the warning is justified b=b++ will assign 2 to b then increment b hence 3 is printed -- Amol Sharma Third Year Student Computer Science and Engineering MNNIT Allahabad On Sun, Jul 31, 2011 at 1:41 AM, Neeraj Gupta neeraj.gupta...@gmail.comwrote: Yes, it's UB. For

Re: [algogeeks] Output Help.

2011-07-30 Thread Sanchit Manchanda
I am getting b=2. Maybe coz we are assigning 2 to b then incrementing b. But still acc to me it should be 3. :-\ No warnings in dev cpp. On Sun, Jul 31, 2011 at 1:43 AM, Amol Sharma amolsharm...@gmail.com wrote: yup it is undefined and the warning is justified b=b++ will assign 2 to b then

Re: [algogeeks] Output Help.

2011-07-30 Thread Kamakshii Aggarwal
@sanchit:it is undefined.. On Sun, Jul 31, 2011 at 1:47 AM, Sanchit Manchanda sanchit...@gmail.comwrote: I am getting b=2. Maybe coz we are assigning 2 to b then incrementing b. But still acc to me it should be 3. :-\ No warnings in dev cpp. On Sun, Jul 31, 2011 at 1:43 AM, Amol Sharma

Re: [algogeeks] Output Help.

2011-07-30 Thread Sanchit Manchanda
I dint get any error, not even warning. it might depend from compiler to compiler. but yeah it should be undefined. On Sun, Jul 31, 2011 at 1:49 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: @sanchit:it is undefined.. On Sun, Jul 31, 2011 at 1:47 AM, Sanchit Manchanda

Re: [algogeeks] Output Help.

2011-07-30 Thread gaurav gupta
bt y it sud b undefind? On Sun, Jul 31, 2011 at 1:51 AM, Sanchit Manchanda sanchit...@gmail.comwrote: I dint get any error, not even warning. it might depend from compiler to compiler. but yeah it should be undefined. On Sun, Jul 31, 2011 at 1:49 AM, Kamakshii Aggarwal kamakshi...@gmail.com

Re: [algogeeks] Output Help.

2011-07-30 Thread Kamakshii Aggarwal
@gaurav:refer the link below http://c-faq.com/expr/seqpoints.html On Sun, Jul 31, 2011 at 1:53 AM, gaurav gupta grvgupta...@gmail.com wrote: bt y it sud b undefind? On Sun, Jul 31, 2011 at 1:51 AM, Sanchit Manchanda sanchit...@gmail.comwrote: I dint get any error, not even warning. it

Re: [algogeeks] Output Help.

2011-07-30 Thread gaurav gupta
thanx kamakshi On Sun, Jul 31, 2011 at 1:56 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: @gaurav:refer the link below http://c-faq.com/expr/seqpoints.html On Sun, Jul 31, 2011 at 1:53 AM, gaurav gupta grvgupta...@gmail.comwrote: bt y it sud b undefind? On Sun, Jul 31, 2011 at