{ A destination to learn coding }

Conditional Statements

If Conditional statements are also known as selective statements.


If Statement

Syntax:
if(expression)
	statement;

else statement

In an if-else statement, if the expression is true (which returns any non-zero interger), the if statement is executed. If it is false (which returns 0) then the else statement is executed.
In an if-else statement, either of the code block is executed and not the both.

Example
#include<stdio.h>
int main()
{
	int a,b,sum;
	printf("Enter any two integers\n");
	scanf("%d%d",&a,&b);
			
	sum=a+b;
			
	if(sum>=50)
	  printf("The sum is greater than or equal to 50\n");
			
	else
	  printf("The sum is less than 50\n");
			
	return 0;
}		
			

The else statement is optional. If there is no else statement no action will be taken after the execution of if statement.

Try this
Finding odd and even numbers
C Codes