This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

my function keeps returning the wrong value

TbooleanVALUE showNUMBER ( int number )
{

switch (number)
 {
 case 0: printf("0"); break;
 case 1: printf("1"); break;
 case 2: printf("2"); break;
 case 3: printf("3"); break;
 case 4: printf("4"); break;
 case 5: printf("5"); break;
 case 6: printf("7"); break;
 case 7: printf("8"); break;
 case 8: printf("9"); break;
 case 9: printf("9"); break;
 }

if ( number > 5 )
  return FALSE ;

if ( number < 2 )
  return TRUE;

  return 2;

}



Parents
  • What value are you passing to the function?

    If you give it a value of 2, 3, 4 or 5 then the function should return 2.

    What are TRUE and FALSE defined as? A boolean is normally used to represent YES or NO, TRUE or FALSE. It is not (normally) used to return YES or NO or 'something else'.

Reply
  • What value are you passing to the function?

    If you give it a value of 2, 3, 4 or 5 then the function should return 2.

    What are TRUE and FALSE defined as? A boolean is normally used to represent YES or NO, TRUE or FALSE. It is not (normally) used to return YES or NO or 'something else'.

Children
No data