Mega Code Archive

 
Categories / C / Code Snippets
 

Use two if statements

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