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();
}
No comments:
Post a Comment