Saturday, 4 October 2014

IF - ELSE STATEMENT

This If - Else statement comes in the decision taking group. It is the basic part of the decision taking group. 

Syntax:

if(condition)
       statement1;
else
       statement2;


This is the syntax of the If - Else statement. Lets undrestand it

first the compiler will see the condition which is kept inside the if()
If it will satisfies the condition then it will print the statement1 otherwise it will go to print statement2.

 Write the program to find maximum number out of two integer number:

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

void main()

{

           int a,b;
           printf("Enter the value of a:");
           scanf("%d",&a);
           printf("Enter the value of b:");
           scanf("%d",&b);
           
           if(a>b)
                  printf("maximum number is %d",a);
           else
                 printf("minimum number is %d",b);
            getch():
}

No comments:

Post a Comment