-->

Facebook

Jasper Roberts - Blog

Wednesday, October 1, 2014

if else statement

-   In, if else statement, if the condition is true than statement(s)-1 is executed.

-   If the condition is false then statement(s)-2 is executed.




-   Syntax:
               if(condition)
               {
                          Statement(s)-1;
                }
              else
              {
                        Statement(s)-2;

              }

-   Flow chart:


if else statement
if else statement


- Example: A C program to check the student is pass or fail.

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

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

     if(per>35)
     {
          printf(“Student is pass.”);
     }
     else
     {
          Printf(“Student is fail.”);
     }
    
     getch();
}


OUTPUT:
enter the percentage: 28
Student is fail.


DOWNLOAD          DOWNLOAD
           




No comments:

Post a Comment