C Programming Code Examples C > If Else and Switch Case Code Examples if statement - display a number if user enters negative number if statement - display a number if user enters negative number if (testExpression) { // statements } The if statement evaluates the test expression inside the parenthesis. If the test expression is evaluated to true (nonzero), statements inside the body of if is executed. If the test expression is evaluated to false (0), statements inside the body of if is skipped from execution. // Program to display a number if user enters negative number // If user enters positive number, that number won't be displayed #include <stdio.h> int main() { int number; printf("Enter an integer: "); scanf("%d", &number); // Test expression is true if number is less than 0 if (number < 0) { printf("You entered %d.\n", number); } printf("The if statement is easy."); return 0; }