IF ELSE STATEMENT IN C
The If else statement is used to implement atmost two logical conditions. Example 1: Program to print result by If else
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int m;
printf("Enter your marks:");
scanf("%d",&m);
if(m >= 33)
{
printf("Pass");
}
else
printf("Fail");
getch();
}
- - - OUTPUT - - -
Enter your marks: 35
Pass
Example 2: Even odd program in C
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int n;
printf("Enter any number:");
scanf("%d",&n);
if(n%2 == 0)
{
printf("Even");
}
else
printf("Odd");
#include<conio.h>
void main()
{
clrscr();
int n;
printf("Enter any number:");
scanf("%d",&n);
if(n%2 == 0)
{
printf("Even");
}
else
printf("Odd");
getch();
}
- - - OUTPUT - - -
Enter any number: 3
Odd
Example 3: Leap year program in C
Odd
Example 3: Leap year program in C
#include<stdio.h>
#include<conio.h>
void main()
{
clrscr();
int year;
printf("Enter the year");
scanf("%d",&year);
if(year%4 == 0)
{
printf("Leap year");
}
else
printf("Not leap year");
getch();
}
#include<conio.h>
void main()
{
clrscr();
int year;
printf("Enter the year");
scanf("%d",&year);
if(year%4 == 0)
{
printf("Leap year");
}
else
printf("Not leap year");
getch();
}
- - - OUTPUT - - -
6 Comments
please tell me how to earn rupee to paytm from blog
ReplyDeleteVery soon I'll upload article, how to earn from blogging so keep visiting ...
ReplyDeletehow get ads from adsense
ReplyDeleteI am writing an article on this topic and within just two days I'll post it, on my "Techno Tricks" post, so keep visiting, thanks ...
Deletehow to get ads tellllllllllllllllllllllll meeeeeeeeeeeeeee plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
ReplyDeleteFirst your blog should be six months old along with 20-30 post then apply for adsense ads.....
Delete