guess the output

#include

#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;
}

Comments

  1. sizeof() operator always returns unsigned value.when we compare d with unsigned value d changed to unsigned value 4294967295.so nothing will be printed.
    To get proper output typecaste TOTAL_ELEMENTS to int.
    d<= ((int)TOTAL_ELEMENTS-2)

    ReplyDelete

Post a Comment

Popular posts from this blog