C PROGRAMMING:
/* C PROGRAMMING
The program below computes the Fibonacci series. The series is
stored in a pointer variable that is exchanged between the
functions.
Replace the question marks (?) in the last 6 instances with one
of the following terms: '&', '*', or '.'. */
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
/*
This method computes the Fibonacci series.
Parameter 'n' is the number of Fibonacci Parameters.
'fibs[]' is the array of the Fibonacci sequence*/
int Fibonacci(int n, int fibs[]){
int first = 0, second = 1, next, c;
for(c = 0; c < n; c++){
if(c <= 1)
next = c;
else{
next = first + second;
first = second;
second = next;
}
*(fibs+c) = next;
}
return 1;
}
int main(){
int n;
printf("Enter the number of terms: ");
scanf("%d", &n);
int *fibs;
fibs = malloc(n * sizeof(int));
Fibonacci(n, fibs);
printf("\nThe Fibonacci series are:");
for(int i = 0; i < n; i++){
printf("\nElement %d is %d,", i, fibs[i]);
printf("\nThe address of the element is %p", (fibs + i));
}
return 0;
}