These were before 2023 (then code UTA007)
UTA007.pdf
UTA007 (1).PDF
Answer to some of the questions→

- Scope: The scope of a variable is the part of the program where the variable can be accessed or used. There are two types of scope in C: global scope and local scope. A variable declared outside any function has global scope, meaning it can be accessed by any function in the program. A variable declared inside a function has local scope, meaning it can only be accessed by that function or by other functions nested within it.
- Visibility: The visibility of a variable is the ability of other functions or modules to see or use the variable. Visibility is related to scope, but not the same. A variable with global scope may have different visibility depending on the storage class of the variable. There are four storage classes in C: auto, static, extern, and register. A variable with auto storage class has local visibility, meaning it is only visible within the function where it is declared. A variable with static storage class has local visibility if it is declared inside a function, or file visibility if it is declared outside any function, meaning it is only visible within the file where it is declared. A variable with extern storage class has external visibility, meaning it is visible to any function or file that uses the extern keyword to refer to it. A variable with register storage class has local visibility, and it is stored in a CPU register for faster access.
- Lifetime: The lifetime of a variable is the duration of time during which the variable exists in memory. The lifetime of a variable depends on the storage duration of the variable. There are three types of storage duration in C: automatic, static, and dynamic. A variable with automatic storage duration is created when the function where it is declared is called, and destroyed when the function returns. A variable with static storage duration is created when the program starts, and destroyed when the program ends. A variable with dynamic storage duration is created and destroyed by the programmer using the malloc and free functions.

#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.