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

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,

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

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

[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

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

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

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