Mega Code Archive

 
Categories / C / Code Snippets
 

Use int as if condition

#include <stdio.h> int main(void) { int j; printf("Enter an integer: "); scanf("%d", &j); if(j < 0) printf("Number is negative."); else printf("Number is non-negative."); return 0; }