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

CALCULATE PERCENTAGE

Calculate percentage #include < stdio.h > void main() { int s1, s2, s3, s4, s5, sum, total = 500; float per; printf("\nEnter marks of 5 subjects : "); scanf("%d %d %d %d %d", &s1, &s2, &s3, &s4, &s5); sum = s1 + s2 + s3 + s4 + s5; printf("\nSum : %d", sum); per = (sum * 100)/500; /* percentage formula*/ printf("\nPercentage : %f", per); }

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); }

High level languages

High level languages High level languages were developed for make programming easier.Tgese languages are called higher level languages.Because there syntax is more like human language than assembly or machine language code.Higher level programming languages use familiar words rather than make up machine instructions.To express computer operations.These languages use operators such as the + and - sign that are the familiar components of mathematics.As a result people can read,Write and understand computer programmes much more easily when using a high level language.Still the instructions must be translated inyo machine language before the computer can understand and carry them out.