Mega Code Archive

 
Categories / C Tutorial / Statement
 

Using nested ifs

#include <stdio.h> #include <limits.h> int main(void) {   long test = 0L;                 if( test % 2L == 0L) {     printf("The number %ld is even", test);     if ( (test/2L) % 2L == 0L)     {       printf("\nHalf of %ld is also even", test);       printf("\nThat's interesting isn't it?\n");     }   }   else     printf("The number %ld is odd\n", test);   return 0; } The number 0 is even Half of 0 is also even That's interesting isn't it?