Software & Finance





Turbo C - Simple IF Statement





Here is an example for simple if statement.

 

if statement evaluates the condition inside the paranthesis and if it is true, then it executes one line followed by if statement or the sequence of steps bound of { }.

 

if statement can be combined with else part which is explained in if else statement

 


Source Code


#include <stdio.h>

 

 

void main()

{

   int x;

 

   printf("Enter a Number: ");

   scanf("%d", &x);

 

   if(x < 0)

      printf("%d is a negative number\n", x);

}

 

Output


Enter a Number: -100

-100 is a negative number