Skip to main content

FIBONACCI SERIES USING RECURSION

Fibonacci series using recursion
#include < stdio.h >
int Fibonacci(int);
main()
{
  int n, i = 0, c;
  printf("Enter the number of terms ");
  scanf("%d",&n);
  printf("First %d terms of Fibonacci series are :-\n", n);
  for ( c = 1 ; c < = n ; c++ )
  {
  printf("%d\n", Fibonacci(i));
  i++;
  }
  return 0;
}
int Fibonacci(int n)
{
  if ( n == 0 )
  return 0;
  else if ( n == 1 )
  return 1;
  else
  return ( Fibonacci(n-1) + Fibonacci(n-2) );
  /*adding Fibonacci of (n-1) & (n-2) by recursive calling it*/
}

Comments

Popular posts from this blog

SIMPLE INTEREST

Simple interest #include < stdio.h > void main() { int amount, rate, time, ans; printf("\nEnter Principal Amount : "); scanf("%d", &amount); printf("\nEnter Rate of Interest : "); scanf("%d", &rate); printf("\nEnter Period of Time : "); scanf("%d", &time); ans = (amount * rate * time)/100; /*Simple interest formula*/ printf("\nSimple Interest : %d",ans); }

HCF AND LCM

HCF and LCM #include < stdio.h > long gcd(long, long); int main() {   long x, y, hcf, lcm;   printf("Enter two integers\n");   scanf("%ld%ld", &x, &y);   hcf = gcd(x, y);   lcm = (x*y)/hcf;   printf("Greatest common divisor of %ld and %ld = %ld\n", x, y, hcf);   printf("Least common multiple of %ld and %ld = %ld\n", x, y, lcm);   return 0; } /*if 1st no is 0 then 2nd no is gcd make 2nd no 0 by subtracting smallest from largest and return 1st no as gcd*/ long gcd(long x, long y) {   if (x == 0) {   return y;   }   while (y != 0) {   if (x > y) {     x = x - y;   }   else {     y = y - x;   } } return x; }

System Software

System software Any programs that control the computers hardware or that can be used to maintain the computer in some way so that it runs more efficiently.These are 3 basic types of system software a.Operating System An operating system tells the computer how to use it own components.It is essential, Because it acts as an interface between the hardware, application program and the user Eg: Windows, Linux B.Network operating system Network operating system allows the computer to communicate and share data across a network while controlling network operation and network security. C.Utility Utility is a program that make the computer system easier to use and perform highly specialised function utilities are used to manage disk, trouble shoot hardware problems and perform other task.Operating system may not be able to do.