C If statement

Simple if statement

The general form of a simple if statement is,

Syntax:

if(expression) 
{
    statement-inside;
}
    statement-outside;

If the expression is true, then 'statement-inside' it will be executed, otherwise 'statement-inside' is skipped and only 'statement-outside' is executed.

Example:

//Write a C Program which demonstrate use of if statement.
#include<stdio.h>
#include<conio.h>
void main()
{
    int x,y;
    x = 7;
    y = 5
    if(x > y)
    {
        printf("x is greater than y");
    }
    getch();
}

Output:

Command Prompt
x is greater than y

Share This Page to Download:

Share to Download

Share This Page on:


Ask Question