Friday, 17 May 2013
Thursday, 16 May 2013
Tuesday, 14 May 2013
Sunday, 12 May 2013
Saturday, 11 May 2013
Wednesday, 8 May 2013
Saturday, 4 May 2013
Online Solution for C, C++, VBScript, JavaScript and many to come: A simple program to compare to string whether they...
Online Solution for C, C++, VBScript, JavaScript and many to come: A simple program to compare to string whether they...: #include"stdio.h" #include"conio.h" #include"malloc.h" int main() { char *firstString =(char*)malloc(100); ch...
Friday, 3 May 2013
Here is a program in C++ as how to print the nth number of a Fibonacci series by recursive method
#include"stdio.h"
#include"conio.h"
void main()
{
int num;
long fibo(int);
void printFiboSeries(int);
clrscr();
printf("\nEnter number : ");
scanf("%d",&num);
printFiboSeries(num);
getch();
}
long fibo(int n)
{
if(n<=2)
return 1;
return fibo(n-1) + fibo(n-2);
}
void printFiboSeries(int n)
{
if(n<1 br="">return;
printFiboSeries(n-1);
printf("%d ",fibo(n)); // printf is called when all function call of printFiboSeries is popped up from 1>
// the stack
}
Suppose input variable is 5 then the result should be 5
fibo(5)
fibo(4) + f ibo(3)
fibo(3) + f ibo(2) + fibo(2) + fibo(1)
fibo(2) + fibo(1) + 1 + 1 + 1
1 + 1 + 1 + 1 + 1 = 5
Thursday, 2 May 2013
Wednesday, 1 May 2013
Subscribe to:
Posts (Atom)