Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more ➡
Standard view
Full view
of .
×
0 of .
Results for:
P. 1
c programming using pointers

# c programming using pointers

Ratings:

5.0

(2)
|Views: 21,683|Likes:
this is a collection of c programs using pointers
this is a collection of c programs using pointers

### Availability:

See More
See less

08/03/2013

pdf

text

original

EX NO: IMPLEMENTATION OF RECURSIVE ALGORITHMDATE: USING POINTEAIM:
To write a C-Program to implement a recursive algorithm using pointers
ALGORITHM:STEP 1:
Start the program
STEP 2:
Declare the variable, *no, factorial, sum, p, i, and the function fact(int p),sum(int p), fib(int p)
STEP 3:
.STEP 4:
Call

the function fact(*no), sum(*no)
STEP 5:
Using a for loop call the function fib(int p) and display the Fibonacci series &also display factorial & summation
.STEP 6:
Stop the program
FUNCTION FIB (int p)STEP 1:
Check

whether the value of n is equal to ‘0’ if so return ‘0’
STEP 2:
Else check whether (p>=1 && p<=2), if so return the value ‘1’
STEP 3:
Else return ( fib(p-1)+ fib(p-2))
FUNCTION FACT (int p)STEP 1:
Check whether (p==0), if so return ‘1’
.STEP 2:
Else return (p*fact(p-1))
FUNCTION SUM (int p)STEP 1:
Check whether p==0, if so return ‘0’
STEP 2:
Else return (p+sum(p-1))

PROGRAM:
#include<stdio.h>#include<conio.h>void main(){int i,p, *no,factorial,summ;int fact(int p);int sum(int p);int fib(int p);clrscr(); printf("\n Enter The Number:");scanf("%d",no); printf("\n The Fibonnacci series: \n");for(i=0;i<*no;i++) printf("%d\n",fib(i));factorial=fact(*no); printf("\n The factorial of %d: %d\n", *no,factorial);summ=sum(*no);printf("\nThe summation of %d: %d\n", *no,summ);getch();}int fib(int p){if(p==0)return(0);if(p>=1&&p<=2)return(1);elsereturn(fib(p-1)+fib(p-2));}int fact(int p){if(p==0)return(1);elsereturn(p*fact(p-1));}int sum(int p){if(p==0)return(0);elsereturn(p+sum(p-1));}

OUTPUT:
Enter the Number: 5The Fibonacci series:01123The factorial of 5: 120The summation of 5: 15

## Activity (88)

### Showing

AllMost RecentReviewsAll NotesLikes