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

ProjectLocker - Managed Source Control for Less
Hosted Subversion and Trac over SSL as low as $2.50/month for 1 GB. No-risk trial. Sign up today!
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
PureCM Software Configuration Management
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!
Software Localization Tool Sisulizer
Localize DotNet, C++ Builder, Delphi, C/C++, Visual Basic & Java apps & html help. Try Sisulizer now
Experience Adobe? FLASH MEDIA SERVER 3
Introducing the media solution for total action without interruption. TRY IT NOW FOR FREE!


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.