Re: [algogeeks] C Problem
+1 to yogesh -- 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] C Problem
#includestdio.h int main() { int a=5; printf(Size : %d\n,sizeof( a =15/2)); printf(A is %d.,a); } What will be the value of a now ? Plz explain. Sanju :) -- 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] C Problem
4,5 statements inside sizeof() does not get executed...it will tell just size... int a=3; printf(%d,sizeof(a++)); here a++ will not be executed ...it will just tell size ... Also, lets suppose it execute statements ...then sizeof(int),sizeof(node *) ...will always produce error because int and node* are not executable statements On Sat, Sep 17, 2011 at 2:48 PM, prasanth n nprasnt...@gmail.com wrote: 4,7..if we assume the sizeof(int) as 4 bytes.. On Sat, Sep 17, 2011 at 2:32 PM, abhinav gupta abhinav@gmail.comwrote: Ans will be:4,5 On Sat, Sep 17, 2011 at 2:23 PM, Sanjay Rajpal srn...@gmail.com wrote: #includestdio.h int main() { int a=5; printf(Size : %d\n,sizeof( a =15/2)); printf(A is %d.,a); } What will be the value of a now ? Plz explain. Sanju :) -- 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. -- *prasanth* -- 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] C Problem
4 and 5. size of will check its first operand. so no evaluation takes place... On Sat, Sep 17, 2011 at 2:32 PM, abhinav gupta abhinav@gmail.comwrote: Ans will be:4,5 On Sat, Sep 17, 2011 at 2:23 PM, Sanjay Rajpal srn...@gmail.com wrote: #includestdio.h int main() { int a=5; printf(Size : %d\n,sizeof( a =15/2)); printf(A is %d.,a); } What will be the value of a now ? Plz explain. Sanju :) -- 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] c problem
@Priya: Lvalue is not a contant value. It can be modifiable or unmodifiable. Lvalue stands for location value that means that we can store some value here in this location and rvalue stands for read value that means that it can be stored at some location that is in memory having lvalue. Here in case of array a[]. a is unmodifiable Lvalue(Location). That means it can be used in left hand side of assignment operator because its memory location. i.e a[1]=5; it is a location of array having index 1 contaioning value as 5. Here 5 was a RValue(Read Value) because it can be assigned to the LValue Variable. According to you it is a RValue(Read Value).If it is so then this program should work a[]={1,2,3}; b[]; b=a; But it does not . Because a is not a value that can be read .It was a memory location.So we cannot assign array a to array b. For this we have to use memset(b,a,sizeof(b)) On Sat, Sep 3, 2011 at 11:10 PM, priya ramesh love.for.programm...@gmail.com wrote: if it is an l value, the compiler should say cannot modify const value instead it says l value required This statement proves that a is an r value in main. right?? -- 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] c problem
@yogesh: Thanks a lot for the explaination. Good one indeed. Can you plz tell me y the compiler says lvalue required for the statement a++ when a is an lvalue?? -- 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] c problem
@Priya: Because a is *unmodifiable* LValue. When we are using a=a+1(a++) , this means that we are changing the *base address* of array a[], and that can not be possible due to Library files. On Sun, Sep 4, 2011 at 11:49 AM, priya ramesh love.for.programm...@gmail.com wrote: @yogesh: Thanks a lot for the explaination. Good one indeed. Can you plz tell me y the compiler says lvalue required for the statement a++ when a is an lvalue?? -- 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] c problem
@priya: compiler thinks that a++; statement is correct... But for that to do...' a' should be of type modifiable ... so it gives error saying that If u want to modify , that should be lvalue, so lvalue required On Sun, Sep 4, 2011 at 2:27 AM, Yogesh Yadav medu...@gmail.com wrote: @Priya: Because a is *unmodifiable* LValue. When we are using a=a+1(a++) , this means that we are changing the *base address* of array a[], and that can not be possible due to Library files. On Sun, Sep 4, 2011 at 11:49 AM, priya ramesh love.for.programm...@gmail.com wrote: @yogesh: Thanks a lot for the explaination. Good one indeed. Can you plz tell me y the compiler says lvalue required for the statement a++ when a is an lvalue?? -- 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. -- **Please do not print this e-mail until urgent requirement. Go Green!! Save Papers = Save Trees *BharatKumar Bagana* **http://www.google.com/profiles/bagana.bharatkumarhttp://www.google.com/profiles/bagana.bharatkumar * Mobile +91 8056127652* bagana.bharatku...@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] c problem
In main, any array say char a[200], a refers to an r value or an lvalue?? -- 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] c problem
an array is always an *unmodifiable* l-value. On Sat, Sep 3, 2011 at 6:23 PM, priya ramesh love.for.programm...@gmail.com wrote: In main, any array say char a[200], a refers to an r value or an lvalue?? -- 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 Himanshu Kansal Msc Comp. sc. (University of 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] c problem
ok but y does the compiler say lvalue required if you perform 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] c problem
lvalue On Sat, Sep 3, 2011 at 6:44 PM, himanshu kansal himanshukansal...@gmail.com wrote: an array is always an *unmodifiable* l-value. On Sat, Sep 3, 2011 at 6:23 PM, priya ramesh love.for.programm...@gmail.com wrote: In main, any array say char a[200], a refers to an r value or an lvalue?? -- 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 Himanshu Kansal Msc Comp. sc. (University of 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. -- 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] c problem
@priya :array is a constant pointer to a non constant data remember On Sat, Sep 3, 2011 at 6:48 PM, priya ramesh love.for.programm...@gmail.com wrote: ok but y does the compiler say lvalue required if you perform 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. -- 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] c problem
if it is an l value, the compiler should say cannot modify const value instead it says l value required This statement proves that a is an r value in main. right?? -- 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] c problem
can any one tell me why this code perfectly running and giving ouput 56 int main() { int *p=malloc(0); *p=56; printf(%d,*p); 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] c problem
This depends upon the implementation. Hence, your program is not portable. It's allowed to return NULL, and it's allowed to return a non-NULL pointer. Both ways are sanctioned by the Standard. On Wed, Jun 8, 2011 at 4:20 PM, coder dumca coder.du...@gmail.com wrote: can any one tell me why this code perfectly running and giving ouput 56 int main() { int *p=malloc(0); *p=56; printf(%d,*p); 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. -- Harshal Choudhary, III Year B.Tech CSE, NIT Surathkal, Karnataka, India. -- 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] c problem
@harshalthanks , can u tell me how to find what features are compiler dependent On Wed, Jun 8, 2011 at 4:28 PM, Harshal hc4...@gmail.com wrote: This depends upon the implementation. Hence, your program is not portable. It's allowed to return NULL, and it's allowed to return a non-NULL pointer. Both ways are sanctioned by the Standard. On Wed, Jun 8, 2011 at 4:20 PM, coder dumca coder.du...@gmail.com wrote: can any one tell me why this code perfectly running and giving ouput 56 int main() { int *p=malloc(0); *p=56; printf(%d,*p); 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. -- Harshal Choudhary, III Year B.Tech CSE, NIT Surathkal, Karnataka, India. -- 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] C++ problem..
Change it to that.. It will still work.. Don't worry :) On Tue, May 24, 2011 at 10:56 PM, Balaji S balaji.ceg...@gmail.com wrote: but constructor is A(int *m=0*) { a=m; } not A*(int m*) { a = m; } ??? -- 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. -- -Aakash Johari (IIIT 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] C++ problem..
ya.. thanks :) it works. but.. we are initializing m to 0 in everycall ryt.. ? then how does 1,2,3,is initialized?? -- 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] C++ problem..
Actually A(int *m=0*) { a=m; } not A*(int m*) { a = m; } means m has a default value of 0 ie this value will be used if no parameter is given . So when you pass it a parameter default value is simply ignored. On Wed, May 25, 2011 at 12:15 PM, Balaji S balaji.ceg...@gmail.com wrote: ya.. thanks :) it works. but.. we are initializing m to 0 in everycall ryt.. ? then how does 1,2,3,is initialized?? -- 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. -- Thanks and Regards , Gaurav Saxena -- 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] C++ problem..
@balaji: that's the default value for the parameter. Basically, the advantage of the default parameter is that you need not to explicitly define the non-parameterized constructor. See the difference yourself with following 2 examples. 1) *class A { int m; A (int a) { m = a; } };* when you declare an obj of the class A as : * A obj;* in main(), then it reports an error. because the class lacks the constructor of the form: * A() { } * 2) *class A { int m; A (int a = 0) { m = a; } };* when you declare an obj of the class A as : * A obj;* in main(), then it doesn't report error. because the default parameter lets the user to skip the explicit(rather strictly) passing the argument value. When user doesn't pass the argument value, it takes it as the default value 0. On Wed, May 25, 2011 at 1:42 AM, Gaurav Saxena grvsaxena...@gmail.comwrote: Actually A(int *m=0*) { a=m; } not A*(int m*) { a = m; } means m has a default value of 0 ie this value will be used if no parameter is given . So when you pass it a parameter default value is simply ignored. On Wed, May 25, 2011 at 12:15 PM, Balaji S balaji.ceg...@gmail.comwrote: ya.. thanks :) it works. but.. we are initializing m to 0 in everycall ryt.. ? then how does 1,2,3,is initialized?? -- 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. -- Thanks and Regards , Gaurav Saxena -- 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. -- -Aakash Johari (IIIT 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] C++ problem..
Answer pls.. ;-) Class A { int a; public: A(int m = 0) { a = m; } int main() { int i = 0; /* Create the 32 Objects { nObjects[32] } of Class A Initialize the nObjects[i].a = i during the constructor call ( 0 = i = 31 ) */ } -- With Regards, Balaji.S -- 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] C++ problem..
This way you can do: #include iostream using namespace std; class A { public: int a; A(int m) { a = m; } A() { } }; int main() { int i; A *obj[32]; for ( i = 0; i = 31; i++ ) { obj[i] = new A(i); } for ( i = 0; i = 31; i++ ) { cout obj[i]-a endl; } return 0; } On Tue, May 24, 2011 at 9:42 PM, Balaji S balaji.ceg...@gmail.com wrote: Answer pls.. ;-) Class A { int a; public: A(int m = 0) { a = m; } int main() { int i = 0; /* Create the 32 Objects { nObjects[32] } of Class A Initialize the nObjects[i].a = i during the constructor call ( 0 = i = 31 ) */ } -- With Regards, Balaji.S -- 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. -- -Aakash Johari (IIIT 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] C++ problem..
but constructor is A(int *m=0*) { a=m; } not A*(int m*) { a = m; } ??? -- 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.