Posts

Showing posts from September 28, 2012

A RECURSIVE FUNCTION TO OBTAIN FIRST N( INPUTTED BY THE USER) NUMBERS OF A FIBONACCI SERIES

Image
LIST OF PROGRAMS

#include<stdio.h>
#include<conio.h>
void main()
{
int t(int n2);
int n,i=1;
clrscr();
printf("ENTER A NUMBERS\n");
scanf("%d",&n);
printf("FIBONACCI SERIES IS :\n");
while(i<=n)
{
printf("\t %d",t(i));
i+=1;
}
getch();
}
int  t(int n2)
{
if(n2==1)
return(0);
else if(n2==2)
return(1);
else
return(t(n2-1)+t(n2-2));
}


LIST OF PROGRAMS

PROGRAM TO FIND FACTORIAL OF A NUMBER AND USE RETURN STATEMENT IN FUNCTION

LIST OF PROGRAMS#include<stdio.h>
#include<conio.h>
long int f=1,j,a;
void main()
{
long int fact(long int a);
clrscr();
printf("enter the number");
scanf("%ld",&a);
f=fact(a);
printf("\nFACTORIAL IS:%ld",f);
getch();
}
long int fact(long int a)
{
for(j=2;j<=a;j++)
f=f*j;
return f;
}

LIST OF PROGRAMS

PROGRAM TO ENTER RADIUS OF A CIRCLE, FIND CIRCUMFERENCE AND AREA WITH THE SPECIFIED AREA USE RETURN IN THE FUNCTION

LIST OF PROGRAMS
#include<stdio.h>
#include<conio.h>
double r,c,a;
void main()
{
double circum(double r);
double area(double r);
clrscr();
printf("enter the radius");
scanf("%lf",&r);
c=circum(r);
a=area(r);
printf("\nAREA IS:%lf",a);
printf("\nCIRCUMFERENCE IS : %lf",c);
getch();
}
double circum(double r)
{
c= 2*3.14*r;
return c;
}
double area(double r)
{
a=3.14*r*r;
return a;
}

LIST OF PROGRAMS

PROGRAM TO ENTER THREE NUMBERS AND PRINT THEIR SUM

LIST OF PROGRAMS
#include<stdio.h>
#include<conio.h>
int x,y,z,su;
void main()
{
void sum(int x,int y,int z);
clrscr();
printf("enter the three numbers");
scanf("%d%d%d",&x,&y,&z);
sum(x,y,z);
getch();
}
void sum(int x,int y,int z)
{
su=x+y+z;
printf("\nSUM IS : %d",su);
}


LIST OF PROGRAMS