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:
> #include<stdio.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:
>>>> > #include<stdio.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.

Reply via email to