Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Fibonacci Sequence The Fibonacci sequence is the series of numbers: 0, 1, 1, 2,

ID: 3679171 • Letter: F

Question

Fibonacci Sequence The Fibonacci sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13,.... The next number is found by adding up the two numbers before: F(n) - F(n-1)+ F(n-2) F(0) 0 and F(1) 1 and Write a recursive function that takes an integer n as input and returns the nth number in the Fibonacci series. Write a program fibonacci.c that asks the user to enter an integer and uses the function above to print out the corresponding Fibonacci number. Your program must validate the input is positive Array Reversal Write a recursive function that takes an array of decimals as input and prints it content in reverse order, each value on a separate line, always showing the sign. Write a program arrayReverse.c that asks the user to enter a number corresponding to the number of decimal values to be stored. Your program should then ask the user to enter those values and store them in an array. Use the function you wrote to print the array in reverse order Integer Reversal Write a recursive function that takes an integer as input and prints its digits in reverse order. Write a program intReverse.c that asks the user to enter an integer use the function you wrote to print the digits in reverse order. Submit through handin the 3 C programs you wrote: fibonacci. c, arrayReverse.c, intReverse.c

Explanation / Answer

Fibonacci Series

#include<stdio.h>

#include<conio.h>

int fibonacciPrint(int);

main()

{

   int n, i = 0, c;

printf(“enter the range of series”);  

scanf("%d",&n);

   printf("Fibonacci series ");

   for ( i = 0 ; i < n ; i++ )

   {

      printf("%d ", Fibonacci(i));

   }

   return 0;

}

int fibonacciPrint(int c)

{

   if ( c == 0 )

      return 0;

   else if ( c == 1 )

      return 1;

   else

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

}

Array Reversal:

# include<stdio.h>

#include<conio.h>

void reverseArr(int [], int);

int main()

{

int arr[5];

int i=0;

printf("enter the elements of array");

for(i=0;i<;i++)

{

scanf("%d",&arr[i]);

}

int size=5;

reverseArr(arr[], size);

return 0;

}

void reverseArr(int a[], int s)

{

if(s==0)

return;

else

{

printf("%d ",a[n-1]);

reverseArr(a,n-1);

}

}

Reverse the digits of an integer:

#include<stdio.h>

#include<conio.h>

int main()

{

    int num;

printf(“enter the number to be reversed”);

scanf(“%d”,&num);

int rev= reverseDigits(num);

    printf("Reverse of no. is %d",rev);

    return 0;

}

int reverseDigits(int n)

{

  static int n1 = 0;

  static int base = 1;

  if(n > 0)

  {

    reversDigits(n/10);

    n1 += (n%10)*base;

    base*= 10;

  }

  return n1;

}