Subtle Bug

The variable d is less than the Total elements, but still the if condition did not evaluate to true. Find the Bug.

Code:
#include <stdio.h>
int array_one[]={1,2,3,4,5,6};
#define TOTAL_ELEMENTS (sizeof(array_one)/sizeof(array_one[0]))

int main()
{
  int d=-1;
  if(d<=TOTAL_ELEMENTS)
    printf(“d is less than Total no. of elemnts in the array”); //execution never comes her
  else
    printf(“d is greater than total elements in the array”); //this will get printed
  return 0;
}

Find Answer here

Leave a Reply

Your email address will not be published. Required fields are marked *