+1-617-874-1011 (US)

  +44-117-230-1145 (UK)

If else statement Homework Help

In If Statement, when the condition is true then only the statement is executed. What will happen when the condition is false. Obviously … nothing. Suppose we want something to happen if the condition is false, in that case we use If-Else Statement.

Syntax is as:

if (condition)
{
Statement to be executed when condition is true;
}
else
{
Statement to be executed when condition is false;
}

Example:

#include <stdio.h>
#include <conio.h>
void main()
{
int age;
printf(“Enter your age: ”);
scanf(“%d”,&age);

if (age > 22)
{
printf(“You are older than me.”);
}
else
{
printf(“I am older than you.”);
}
return;
}

If else statement Homework Help

Topics in C Programming