These were before 2023 (then code UTA007)

UTA007.pdf

UTA007 (1).PDF


Answer to some of the questions→

Untitled


Untitled

#include <stdio.h>

void fibonacci(int n) { int i, t1 = 0, t2 = 1, nextTerm;

printf("Fibonacci Series: ");

for (i = 1; i <= n; ++i) {
    printf("%d, ", t1);
    nextTerm = t1 + t2;
    t1 = t2;
    t2 = nextTerm;
}

}

int main() { int n;

printf("Enter the number of terms: ");
scanf("%d", &n);

fibonacci(n);

return 0;

}

This program uses a for loop to generate the first n Fibonacci numbers. The first two numbers in the sequence are 0 and 1, and each subsequent number is the sum of the two preceding numbers. The fibonacci function takes an integer argument n and prints the first n numbers in the sequence. The main function prompts the user to enter the number of terms they want to generate, reads in the input using scanf, and then calls the fibonacci function with the user’s input as an argument.