page2
page2
Date:
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
int a,b,c;
clrscr();
scanf("%d %d %d",&a,&b,&c);
printf("\n----------------------------------");
printf("%d,%d,%d",a,b,c);
else
printf("%d,%d,%d",a,c,b);
}
else
printf("%d,%d,%d",b,a,c);
else
printf("%d,%d,%d",b,c,a);
else
printf("%d,%d,%d",c,a,b);
else
printf("%d,%d,%d",a,b,c);
else
{
printf("%d,%d,%d",c,b,a);
getch();
OUTPUT :-
Practical No :- 3
Date:
#include<conio.h>
void main()
int n,i;
clrscr();
scanf("%d",&n);
for(i=1;i<=n;i++)
printf("%d %d %d\n",i,i*i,i*i*i);
getch();
OUTPUT :-
Practical No :- 4
Date:
Q.1]Given an input positive integer number ,display odd numbers
from in the range[1,n]?
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n;
clrscr();
printf("enter nth number:");
scanf("%d",&n);
for(i=1;i<=n;i++)
{
if(i%2==1)
{
printf("\n odd number is: %d",i);
}
}
getch();
}
OUTPUT :-
Practical No :- 5
Date:
#include<conio.h>
void main()
int i,n,m;
clrscr();
scanf("%d",&n);
scanf("%d",&m);
for(n;n<=m;n++)
for(i=1;i<=10;i++)
printf("\n %d*%d=%d",n,i,(n*i));
}
}
getch();
OUTPUT :-
Practical No :- 8
Date:
Q.1]Given the first term(a), difference/multiplier(d) and number of
terms (n>0), display the first n terms of the arithmetic/ geometric
progression?
A]Arithmetic progression
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
{
int a,b,d,i,n;
clrscr();
printf("enter first two terms of AP\n");
scanf("%d %d",&a,&b);
printf("enter number of term for summation\n");
scanf("%d",&n);
d=b-a;
printf("AP is \n");
for(i=1;i<=n;i++)
{
if(i<n)
{
printf("%d ",a);
a=a+d;
}
else
{
printf("%d",a);
}
}
getch();
}
OUTPUT :-
B]Geometric progression
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
int a,b,d,i,n;
clrscr();
scanf("%d %d",&a,&b);
d=b-a;
printf("\n Difference:%d",d);
scanf("%d",&n);
for(i=0;i<=n;i++)
printf(" %d\t",a);
a*=d;
getch();
OUTPUT :-
Practical No :- 9
Date:
Q.1]Display the first n(n>0) terms of the fibonacci sequence?
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
{
int i,n,t1,t2,nextterm;
clrscr();
t1=0 ;
t2=1;
nextterm=t1+t2;
printf("enter the number of terms:");
scanf("%d",&n);
printf("\n fibonacci series:%d,%d",t1,t2);
for(i=3;i<=n;++i)
{
printf(",%d",nextterm);
t1=t2;
t2=nextterm;
nextterm=t1+t2;
}
getch();
}
OUTPUT :-
Practical No :- 10
Date:
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
int i,n,t1,t2,t3,nextterm;
clrscr();
t1=0;
t2=0;
t3=1;
nextterm=t1+t2+t3;
scanf("%d",&n);
printf("tribonacci series:%d,%d,%d",t1,t2,t3);
for(i=3;i<=n;++i)
printf(",%d",nextterm);
t1=t2;
t2=t3;
t3=nextterm;
nextterm=t1+t2+t3;
}
getch();
OUTPUT :-
Practical No :- 11
Date:
Q.1]Given two positive integer numbers n1 and n2 check if the
numbers are consecutive numbers of the Fibonacci sequence?
CODING :-
#include<stdio.h>
#include<conio.h>
void main()
int a,b,c,next,num,i;
clrscr();
printf("enter a number:");
scanf("%d",&num);
if(num>0)
printf("number is positive");
for(i=0;i<=num;i++)
a=0;
b=1;
c=a+b;
while(c<i)
a=b;
b=c;
c=a+b;
}
if(c==i)
else
else
printf("number is negative");
getch();
OUTPUT :-
Practical No :- 12
Date:
CODING :-
#include<stdio.h>
#include<conio.h>
#include<math.h>
double compute_pi(int n)
double pi=0.0;
int i;
for(i=0;i<n;i++)
pi+=term;
return 4*pi;
void main()
int n;
double pi;
clrscr();
printf("enter the number of terms(n>0):");
scanf("%d",&n);
if(n<=0)
else
pi=compute_pi(n);
getch();
OUTPUT :-
Practical No :- 13
Date:
Q.1]Compute approximate value of ex considering first n(n>0) terms
of the Taylor series for ex ?
CODING :-
#include<stdio.h>
#include<conio.h>
#include<math.h>
int i;
fact *= i;
return fact;
double result=0.0;
int i;
result += pow(x,i)/factorial(i);
}
return result;
void main()
int n;
double x;
clrscr();
scanf("%lf",&x);
scanf("%d",&n);
if(n<=0)
else
getch();
OUTPUT :-
Practical No :- 14
Date:
Q.1]Compute approximate value of sin(x)/cos(x) considering first n(n>0)
terms of the Taylor series for sin(x)/cos(x)?
CODING :-
#include<stdio.h>
#include<conio.h>
#include<math.h>
int i;
fact *= i;
return fact;
double sin_x=0.0;
double cos_x=1.0;
int i;
void main()
int n;
double x;
clrscr();
scanf("%lf",&x);
scanf("%d",&n);
if(n<=0)
else
getch();
OUTPUT :-