-->

Facebook

Jasper Roberts - Blog

Monday, March 2, 2015

if...else statement in C language.

 - In C programming language, c provides if...else statement to take two-way decision.
 - If the condition is true than it will execute the statement(s)-1, if the condition is false than it will execute the    statement(s)-2.
 - In C, Simple if statement provides only one way decision but if...else statement provides two-way                 decision.
 - If the statements are more than one than it will be written in { and } braces.

Syntax:
            if(condition)
                      statement(s)-1;
            else
                      statement(s)-2;

Example:
#include<conio.h>
#include<stdio.h>


void main()
{
     float per;
     clrscr();
     printf("enter the percentage:");
     scanf("%f",&per);

   if(per>=35)
            printf("You are Pass!");
   else
             printf("Sorry!! You are Fail!!");

   getch();
}

OUTPUT:
enter the percentage: 40
You are Pass!

RELATED TOPICS
Simple if statement.
if...else if ladder(multiple if else).
Switch...case Statement in C programming language.

No comments:

Post a Comment