Program
of if else keyword in c
· /* program to print greater
number */
#include<stdio.h>
void main()
{
int x,y;
printf(“enter the two number”);
scanf(“%d%d”,&x,&y);
if(x>y)
printf(“%d is greater”,x);
else
printf(“%d is greater”,y);
}
· /* program to print number
is odd or even */
#include<stdio.h>
main()
{
int x;
printf(“enter
a number”);
scanf(“%d”,&x);
if(x%2==0)
printf(“%d
is even”,x);
else
printf(“%d
is odd”,x);
}
· /* program to print the
year is leap or not */
#include<stdio.h>
main()
{
int y;
printf(“enter
the year”);
scanf(“%d”,&y);
if(y%4==0)
printf(“%d
is leap year”);
else
printf(“%d
is not leap year”);
}
Or
/* program to print the
year is leap or not */
#include<stdio.h>
main()
{
int y;
printf(“enter
the year”);
scanf(“%d”,&y);
if((y%4==0
&& y%100!=0) || (y%400==0))
printf(“%d
is leap year”,y);
else
printf(“%d
is not leap year”,y);
}
No comments:
Post a Comment