/*PROGRAM TO ÖUADRATIC EQUATION [C.
H-06(14L
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
£loat a,b,c,P 9,di
clrscr()
Printf ("Enter the value of a,b,ci\n")
scanf ("%EVÉK£", &a, &b, &c)
d= (b*b-4*a*c) ;
pa-b/(2*a)
g sqrt (fabs (d)) / (2*a)
if (d>0)
%£\EE\E",p+gP
printf ("The roots a r e . real and unequal and they are
if (d==0) %£\E%£\E",P»P) i
and they are
printf ("The r o o t s are real and equal
if (d<0)
%£+%£i\t%fsfi",p,gPr-9)
1
printf("The roots are 'complex and they are
getch ()
EX->2-/*PROGRAM TO [c.H-2006(12b)]*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
int sum=0,i1
clrscr()
for (i=11i<=1001i++)
sum=sum+i series is = %d, sum) ;
ansver the sum of. the givin
printf ("Required
getch(O.
N,[C.H-2006(13a) *
Exx>3:-/*PROGRAM TO COMPUTE FACTORIAL
# i n c l u d e < s t d i o . h >
#include<conio.h>
void main ()
{ int fact=1
i n t n,i1long
clrscr()1 positive number\n")
a
printf ("Enter
scanf ("zd",kn)
for (i=11i<=n1i++)
f a c t fact*i1
answer is %ld", fact)
printf ("Required
getch ()
[c.H-2006(13b)]*/
Ex4-/*PROGRAM TO ASCENDING ORDER
#include<stdio.h>
#include«conio.h»
void main ()
1
int i,j,n, ti
£loat a[50)
clrscr()1
printf (""Enter n\n")
scanf("%d", kn);
printf(UEnter the elements \n")1
for (i=1l,i<=nji++)
scanf ("%£", ka
for (i=11i<nji++)
[il)
for (j=i+11j<=n1j++)
i f(a [il>alj1)
t=a[il
a lil=a[l
a ljl=t?
1s\n") 1
PTintf ("Ascending order of given numbers
for (i=11i<=nji++)
printf(%E\E",alil)
getch ())7
EX->5: -/*PROGRAM TO sINE SERIES [C.H. -2007(12a)] *Z
#include«stdio.h>
#include<conio.h>
#include<math.h>
void main ()
{
int n, i,j1float x,s um=0, fact, termi
clrscr ()1
printf ("Enter n and x: \n")
scanf ("%d%f",kn, &x)
for (i=11i<=n1 it+)
term=pow(-1,i-1) *pow (x, 2*i-1)
fact 1
f o r (j=21j«=2*i-11j++)
fact=fact*j
sum=sum+term/fact
of the given s e r i e s is =
f", sum)
printf (The sum
getch ()
(C.H.-2007 (12b)] */
Ex->6:-/*PROGRAM TO
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
{ £loat x, Y, £j
clrscr()
printf ("Enter
x and y: \n")
s c a n f ("%£%f",
&y) 1
&x,
(x+y<=1))
i f ( (x>=0) && (y>=0)&&
f=100* (1-x-y)
else
£=01
printE ("The value of the given funtion is = %f"£) 1
getch ()
Ex->7:-/*PROGRAM TO [lc.H. -2007(13a)] *
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
int ni
clrscr()1
printf ("Enter a nunber: \n")
scanf("%d", &n) ;
if( (n*7==0) && (n*3l =0)) by 3.")1
given number is divisible by 7 but not
printf ("The
else is fail."))
condition
the given
printf ("Test
getch(0;
Ex->8: -/* PR0GRAM FIND
THE FIRST DIGIT *
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
long i n t n^int t;
clrscr () number:")
a
printf ("Enter
scanf ("$1d", &n)
i f (n«o0)
n=-nj
while (n>0)
t=n10D
n=n/1L0
is=%d", t)
first digit
printf("The
getch ()1
DIGIT *
FIND THE SECOND
EX->9:-/* PROGRAM
# i n c l u d e < s t d i o . h >
# i n c l u d e < c o n i o . h >
# i n c l u d e < m a t h . h >
void main ()
njint t
long int
clrscr()7
number:")
a
printf ("Enter
scanf ("%1d", &n)
i f (n<o)
n=-n
3
while (n>10)
t=n%10D
n=n/100
printf ( "The second digit is=%d",t) 1
getch ()
EX->10:-/* PROGRAM FIND THE sUM OF DIGITS *
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
long int n^int t,sum=01
clrsc ()1
printf ("Enter a number:")
scanf ("%ld", &n)1
if (n<0)
n=-ni.
while (n>0)
t=n%107
sum=sum+tz
n=n/107
print£ ("The sum of digits is=%d",sum)
getch ()
Ex->11:-/* PROGRAM FIND THE PRODUCT
OF DIGITS*/
#include<stdio.h>
#include<conio.h>
#include<math.h»
void main ()
long i n t njint t,prod=1
clrscr ()
a number:")1
print£ ("Enter
scanf ("%1d", &n);
i f (n<0)
n=-nj
while (n>0)
t=n%10
prod=prod*t
n=n/10
is=%d",prod)
of digits
printf ("The product
getch ()
THE BIGGEST DIGIT */
PROGRAM FTND
EX-2124-/*
# i n c l u d e < s t d i o . h >
# i n c l u d e « c o n i o . h >
#include<math.h>
void main ()
long int njint t,max=01
clrscr()1 number:");
printf("Enter a
scanf(gid",kn)
if (n«0)
n=-n
while (n>0)
t=n%10
if (max<t)
max=t
n=n/10
printf( "The biggest digit is=*d",max) 1
getch ()
x->13: -/* PROGRAM FIND THE SMALLEST DIGIT *Z
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
long int n;int t,min=101
clrscr0
number:")
printf ("Enter a
scanf ("%ld", &n) ;
if (n«0))
n=-n
while (n>0)
t=n%100
if (min>t)
min=t
n=n/10D
smallest digit is=%d",min)
printf ("The
getch ()
Ex->14:-/*PROGRAM TO SIMPSON'S 1/3 RULE *
#include«stdio.h>
#include<conio.. h»
#include<math.h>
float f (float x)
.return (sin (x*x) )1
void main ()
float a,b,h,sum;
int n,i
clrscr()
printf ("EnteI the values of a and b:")1
4 65
scanf ("g£%£",&a,&b)
printf ("Enter the value of n:a)
scanf ("%d",kn)
if (n21 =0)
printf("The s impson's 1/3 rule is not
value of n:") app1icable again enter the even
else
h= (b-a)/nj
sum=f (a) - f (a+n*h)
for (i=1;i<n;i=i+2)
sum=sum+4*f (a+1*h) +2*£ (a+ (i+1) *h)1
sum=sum*h/31
printf ("The value of the
intregration is %8.5f", sum)
getch ()
Ex->154-/*PR0GRAM TO TRAPEZOIDAL RULE +/
#include«stdio.h>
#include<conio.h>
#include<math.h>
float f(float x)
return (pow (x, 3))
void main ()
£loat a,b,h, Sumj
int n, ij
clrsc ()1
printf ("Enter the values of a and b:")
scanf ( "%£*£", &a, &b) 1
printf ("Enter the value of n:\n")
scanf ("%d", &en) i
h= (b-a) /nj
sum= (f (a) +f (a+n*h))/2
for (i=11i<nji++)
sum=sum+£(a+i*h);
sum=sum*h;
value of the intregration is $8.5f",sum)
Print ("The
getch ()
[C.H-2007 (13b)] *Z
EX->16/* PROGRAM To N-R METHOD
#include<stdio.h>
#include<conio.h>
#include<math.h>
float f(float x)
return (x*x+2*x-2)
£loat fd (float x)
return(2 *x+2)
6
void main ()
int k=01 £loat
x0,x11 clrscr ()
Eloat eps=le-51
printf ("/nEnter the initial guess x0\n")
scanf ("%£", &x0) 1
x1=x01
do
x0=xl
xl=x0-f (x0) /fd (x0)
k=k+11
while (fabs (x1-x0) >eps)
printf(one root is s8.5£ obtained at sd th iteration\n ",x1,k)
getch() 1
Ex->17-/* PROGRAM TO DESCENDING ORDER *
#intlude<stdio.h>
#include<conio.h>
void main ()
int i,j,n,ti|
float a[50]7
clrscr()
printf ("Enter n\n")
scanf ("%d", &n)
printf ("Enter the elements\n")
for (i=11i<=n}i++)
scanf ("%£",&.a [i])
for (i=lji<nj i++)
for(j=i+11jc=nij+*)
i f(a [il<aljl)
t a [i1
a [il=a [jl
a [jl=t
}.
printf ( "Descending order of given numbers is\n") ,
for (i=11i<=nji++)
printf ("%£\t",a [il)
getch ()
FUNCTION*/
Ex->18:-/*PROGRAM TO SMALLEST_FACTOR AND PRIME NUMB ER BY
#include<stdio.h>>
#include<conio .h>
smallest_factor (int n)
int
int i=2
while (n*i!=0
i=i+1
return (i)
void main ()
int n, ans
clrscr ()
p r i n t f ("Give n:\n")
scanf ( "%d", kn)
ans smallest_factor
(n) 1
i f (ans==n)
printf (wThe number is prine and smallest factor is itself=kd\n",ans)
else
printf ("The number is not prime and [Link] factor is=%d\n",ans)
getch ()
RECURSION */
Ex->19:-/* PROGRAM TO FACTOR IAL N BY
#include<stdio.h>
#include«conio.h>
1ong int f a c t (int n)
i f ((n==1)|| (n==0))
return (1)
else
return (n*fact (n-1) )
void main ()
{ i n t nj long i n t ans;
clrscr()
printf ("Give n\n")1
scanf ("%d", &n)
ans=fact (n) ; number is=*1d", ans) 1
factorial of a given
printf ("The
getch()7
TRANSPOSE*/
Ex->20:-/*PROGRAM TO MATRIX
#include<stdio.h>
# i n c l u d e < c o n i o . h >
# i n c l u d e < m a t h . h >
void main ()
int i,j,E,C1 £loat a [201 [201l
clrscr () s i z e of a matrix\n")
the
printf("Enter
scanf ("%d%d", &r,&c)
"Enter the elementes \n");
printf (
for (i=11i<=r; i++)
for (j=1rj<=cj++)
scanf ("%E",ka [il [31)7
for (i=11i<=c1i++)
for (j=11jc=r1++)
printf("%8.3f", a ljl [i])
printf("\n")
getch()
8
ELEME
EX >3 -7*9ROGRAM SUM OF DIAGONAL
#include<stdio.h>>
#include<conio.h>
#include<math.h>
void main ()
clrscr (01
sum=01
1nt i,Jm,nj £loat a [20] [201 ,
Print ("Enter m:\n")
scanf ("%d",&m) of a
mattrix\n") 1
elements
pTintE ("Enter
for (i=11i<=mji++)
for (j=l1j«=m/ j++)
[jl)7
scanf ("%£",ka [il
for (i-11i<=mji++) matrix 1s\n"
a square
sum=sum+a[il [il elements
of
diagonal
sum of the
pElntt ("The
sum)
print£ ( "%8.3E",
getch ())
NOT_*/
TEST A NUMBER IS PRTME OR
EX->32-/*PROGRAM
TO
#include<stdio.h>
#include<conio.h>
void main ()
int n,i+2
clrscr()
n : \n") 1
p r i n t f ("Give
s c a n f ("%d",
n) ;
while (n%il=0)
i++1
i f (n==i) number. \n) 7
number is a prime
print£ ("The
else number is not prime. \n")
p r i n t f ("The
getch()7
(C.H-2008 (13c) ]*/
Ex->33-/*PROGRAM TO G.C.D/H.C. F
#include<stdio.h>>
#include<conio.h>>
void main ()
t j c l r s c r ()
int i, a n s , x , Y , x and y\n"),
two n u m b e r s
print£ ("Give &y)7
("%d%d", &x,
scanf
i f (x<y)
t=x
x=Y1
y=t
for (i=11ic=x1i++)
&& (y%i==0))
i f ( (x*i==0)
ans=i factor is =%d\n",ans)
"Greatest comnon
printf (
getch()
Ex->34/*PROGRAM TO L.C.M *Z
# i n c l u d e « s t d i o . h >
# i n c l u d e « c o n i o . h >
void main ()
int i,ans,x,Yt,prod, l
clrscr() x and y\n")
two numbers
printf ("give
scanf ("%d%d", &x, &y)1
if (x<y)
t=x1
x=Y1
y=t
for (i=1,i<=x1i++)
if( (x*i==0) && (y%i==0)
ans=i1
prod=x*y
l=prod/ans;.
printf ("LCM of given two numbers is=%d\n", 1) 1
getch ()"
EX->35:-/*FIBONACI SEQUENCE *
#include«stdio.h>
#include«conio.h>
#include<math.h>
void main ()
int i,x,y, z,n;clrscr ()
printf ("Enter the desired terms ns ")
scanf ("%d",&n)
x=01
=1
printf ("%d\t",Y)1
for (i=l1icn,i++)
Z=X+Y1
x=Y1
Y=Z
printf ("%d\t", z)
getch ()
Ex->36: -/*PROGRAM TO CHECK THE AMSTRONG NUMBER*
#include<stdio.h>
#include<conio .h>
#includecmath.h>
void main ()
int num, n, sum=0, tyclrscr () 1
printf("Enter the number n: ")
scanf ( "zd", &n)
num=nn7
while (n>0)
t=n%10
n=n/107
sum=sum+t*t*t;
if (num==sum)
printf ("The given number is a anstrong number.")
else
printf (mThe given number is not a amstrong number,")
getch (0
Ex->37:-/*PROGRAM To FIND THE_AMSTRONG NUMBERS FROM 100 To 999 *
#include<stdio.h>
#include«conio.h>
#include<math.h>
void main ()
int num,n, sum, t1 clrscr ()
printf ("The amstrong numbers are: \n")1
for (num=100 1 num<=999num++)
n=numn7
sum=0
while (n>0)
t=n%10
n=n/10
sum=sum+pow ( t,3)
i f (num==sum)
printf("%á\t",num) s
getch()
Ex->38:-/*PROGRAM TO CHECK THE PALTNDROME NUMBER*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
int num,n, sum=0,ty clrscr{)
print£ ( "Enter the nunber:")
scanf ( "%d", &nuu)
n=num
while (n>0)
t=n*10
sum=sum*10+t;
n=n/lO7
i f (num==sumn)
printf ("The number %d i s palindrome",num)
else
printf ("The number %d is not palindroma" , Dum)
getch()
E 39/*PROGRAM TO SINE SERIES USING fabs (O FUNCTION*Z
#incrúde<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
Eloat x,t,s1int n=l1clrscr();
printf("Bnter the value of «*")
scanf("%E",kx);
t=x S=x1
while (fabs (t) >10.0e-8)
{
t=t(-(x*«)/(2.0 (2*n+1)))
S=S+t7
n++}
printf ( "The sum of the series=%E" , s)
getch():
EX->40:-/*PROGRAM To FIND THE MAXIMUM AMONG N NUBERS*/
#include<stdio.h>
#include<conio.h>
#include<math. h>
void main ()
Eloat arr[501 ,max1int n,irclrscr ();
printf ("How many numbers will you enter: \n")i
scanf ("%d",&n) ;
printE ( "Enter the sd nmbers : \n",n)
for (i=01i<ni++)
scanf("%E" , &arr [i1)
max=arr [0] 1
for (i=l1i<n;i++)
{
if (arr {i] >max
max=aII [il
else
max=maxj
printf ("The maximum number is=*f",max)
getch ()
Ex->41/+PROGRAM To FIND THE MAKIKUM ANONG THREE NUMBRRS
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main ()
float a,b,c,max;
clrscr ()
printf ("Enter the three numbers: \n")