Programs To Print
Programs To Print
void main()
{
int x;
clrscr();
printf("\n enter no");
scanf("%d",&x);
if(x%2==0)
{printf("even");
}
else
{
printf("odd");
}
getch();
}
Output:
Write a Program to Check Between Three NUmbers.
Which is Greater By NESTED_IF.
SOURCE CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\n Enter Three Number");
scanf("%d%d%d",&a,&b,&c);
if(a>b)
{
if(a>c)
{
printf("a is Greater");
}
else
{
printf("c is Greater");
}
}
else
if(b>c)
{
printf("b is Greater");
}
else
{
printf("c is Greater");
}
getch();
}
OUTPUT:-
1
2
Write a Program To Display The Month Of a Year.
SOURCE_CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int c;
clrscr();
printf("\n Enter The Month In Number");
scanf("%d",&c);
switch(c)
{
case 1 : printf("JANUARY");
break;
case 2 : printf("FEBUARY");
break;
case 3 : printf("MARCH");
break;
case 4 : printf("APRIL");
break;
case 5 : printf("MAY");
break;
case 6 : printf("JUNE");
break;
case 7 : printf("JULY");
break;
case 8 : printf("AUGUST");
break;
case 9 : printf("SEPTEMBER");
break;
case 10: printf("OCTOBER");
break;
case 11: printf("NOVEMBER");
break;
case 12: printf("DECEMBER");
break;
default: printf("INVALID MONTH");
}
getch();
}
OUTPUT:-
1
Write a Program To Find The Sum of The Series.
1+3+5+7+9.......n
SOURCE CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,x=1;
clrscr();
printf("\n Enter any Number:-");
scanf("%d",&n);
while (n>0)
{
s=s+x;
printf(" %d+",x);
x=x+2;
n--;
}
printf("\n Sum =%d",s);
getch();
}
OUTPUT:-
1
Write a Program To find the Sum of the
Natural Number.
SOURCE CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0;
clrscr();
printf("\n Enter any Number:-");
scanf("%d",&n);
while (n>0)
{
s=s+n;
n--;
}
printf("\n Sum Is %d",s);
getch();
}
OUTPUT:-
1
Write a Program To Find The Sum of The Series.
2+4+6+8+10.......n
SOURCE CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int n,s=0,x=2;
clrscr();
printf("\n Enter any Number:-");
scanf("%d",&n);
while (n>0)
{
s=s+x;
printf(" %d+",x);
x=x+2;
n--;
}
printf("\n Sum =%d",s);
getch();
}
OUTPUT:-
1
Write a Program To Find Area of
TRIANGLE,RECTANGLE,CIRCLE By Using SWITCH.
SOURCE_CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,ch;
clrscr();
printf("\n Choose 1 for Find Area of RECTANGLE");
printf("\n Choose 2 for Find Area of CIRCLE");
printf("\n Choose 3 for Find Area of TRIANGLE");
printf("\n OPTION PLEASE");
scanf("%d",&ch);
switch(ch)
{
case 1:printf("\n Enter Two Number");
scanf("%d%d",&a,&b);
a=a*b;
printf("\n Area of RECTANGLE is %d",a);
break;
case 2:printf("\n Enter Any number") ;
scanf("%d",&a);
a=(22*a*a)/7;
printf("\n Area of CIRCLE is %d",a);
break;
case 3:printf("\n Enter Two Number");
scanf("%d%d",&a,&b);
a=(a*b)/2;
printf("\n Area of Triangle is %d",a);
break;
default:printf("\n INVALID OPTION");
}
getch();
}
OUTPUT:-
1
Write a Program To Create a Calculator By Using
Switch.
SOURCE_CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,c;
clrscr();
printf("\nChoose 1 For Addition");
printf("\nChoose 2 For Subtraction");
printf("\n Choose 3 For Multiplication");
printf("\n Choose 4 For Division");
printf("\n OPTION_PLEASE");
scanf("%d",&c);
printf("\n Enter Two Number.");
scanf("%d%d",&a,&b);
switch(c)
{
case 1:a=a+b;
printf("\n ADDITION IS %d",a);
break;
case 2:a=a-b;
printf("\n SUBTRACTION IS %d",a);
break;
case 3:a=a*b;
printf("\n MULTIPLACTION Is %d",a);
break;
case 4:a=a/b;
printf("\n DIVISION IS %d",a);
break;
default:
printf("INVALID");
}
getch();
}
OUTPUT:-
1
2
Write a Program To Find The Factorial of Any
Number.
SOURCE CODE:-
#include<stdio.h>
#include<conio.h>
void main()
{
int n,f=1;
clrscr();
printf("\n Enter any Number:-");
scanf("%d",&n);
while (n>0)
{
f=f*n;
n--;
}
printf("\n FACTORIAL IS %d",f);
getch();
}
OUTPUT:-
1
Find the Area of Triangle By Using
Heron's Formula.
SOURCE_CODE:-
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float a,b,c,p,s,area;
clrscr();
printf("\n Please Enter First edge of the Triangle:-");
scanf("%f",&a);
printf("\n Please Enter Second edge of a Triangle:-");
scanf("%f",&b);
printf("\n Please Enter Third edge of a Triangle:-");
scanf("%f",&c);
p=a=b=c;
s=122;
area= sqrt(s*(s-a)*(s-b)*(s-c));
printf("\n Area of the triangle =%.2f\n",area);
getch();
}
OUTPUT:-