If else Statement Example Program In C Programming Language


IF conditional statement is a feature of this programming language which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition.


	if (expression) {
	else	{

Syntax Example

for example, In c
	if (i == 3) {
	else	{

Syntax Explanation

Consider above example syntax,if (i == 3) 

  • which means the variable i contains a number that is equal to 3, the statements following the doSomething() block will be executed.
  • Otherwise variable contains a number that is not equal to 3, else block doSomethingElse() will be executed.

Example Program For If..else

Example Program For If..else
/* Example Program For If..else In C Programming Language
  little drops @ thiyagaraaj.com
  Coded By:THIYAGARAAJ MP   */

// Header Files

//Main Function
int main()
	// Variable Declaration
	int a;

	//Get Input Value
	printf("Enter the Number :");

	//If Condition Check
	if(a > 10)
	  // Block For Condition Success
	  printf("%d Is Greater than 10",a);
	  // Block For Condition Fail
	  printf("%d Is Less than/Equal to 10",a);

	// Wait For Output Screen
	//Main Function return Statement
	return 0;

Sample Output:

Enter the Number :8
8 Is Less than/Equal to 10

Enter the Number :10
10 Is Less than/Equal to 10


Top Pages