Current area: HOME -> Blogs -> mfarhan133's Blog

data structures

This blog contains the programmes of stacks, queues, linked lists and other other relevant things about data structures
recurrsion examples
Posted on Monday, March 10, 2008 at 4:21 AM
// By muhammad farhan khan 20-02-08



  1. include<iostream.h>
  1. include<conio.h>


int fact(int f) // f!

{

if(f==0)

return 1;

else

return f*fact(f-1);

}



int fibonacci(int n) // series 1 1 2 3 5 8 13 sum of prev two nos

{ // in func n is the index no.

if(n==1||n==2)

return 1;

else

return fibonacci(n-1)+fibonacci(n-2);

}



double pow(int a,int b) // a^b

{

if(b==1)

return a;

else

return a*pow(a,b-1);

}



int mul(int a,int b) // a*b //farhan production

{

if(b==1)

return a;

else

return a+mul(a,--b);

}



int multiply(int a,int b) // sir rashid production

{

if(b==1)

return a;

else

return a+multiply(a,--b);

}



int add(int a,int b) // a+b //farhan production

{

if(b==1)

return ++a;

else

return 1+add(a,--b);

}



int sum(int a,int b) // sur rashid production

{

if(b==0)

return a;

else

Read More
Tags: None

Subscribe

RSS Feed RSS Feed

By Tag



By Month

March 2008

Help

Check out the Blog FAQ.


Sponsored links

Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Six Sigma Certification
100% Online-Six Sigma Certificate from Villanova - Find Out More Now.
Virtual File System SDK
Create your own file systems in Windows and .NET applications
PureCM Software Configuration Management
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!


Newsletter | Submit Content | About | Advertising | Awards | Contact Us | Link to us |
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Synchron Data - .NET development.