If-else Statement


The if-else statement in c language is used to execute the code if condition is true or false.If else is a branching statement.it is use to take an action based on some condition.
for example- if user inputs valid account number and pin, then allow money withdrawal.


Syntax:

if (test expression)

{

    Statement block 1;

}

else

{

Statement block 2;

}

Statement x;


Write a program to find the largest of two numbers


#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,large;
printf("\n Enter the values of a and b: ");
scanf(%d %d", &a, &b);
if(a>b)
{
large=a;
}
else
{
large=b;
}
printf("\n Large = %d", large);
getch();

Comments