Unit 3 - Practice Quiz
CSE109
1 What is the primary purpose of a function prototype in C?
2 If a function does not return any value, its return type must be declared as:
int
null
void
empty
3 In the context of function calls, what are 'actual parameters'?
4 What happens when you pass parameters by value (Call by Value)?
5 Which of the following is strictly necessary for a recursive function to stop?
goto statement
6
Which header file is required to use mathematical functions like pow() and sqrt()?
<stdio.h>
<conio.h>
<math.h>
<stdlib.h>
7
What is the return type of the sqrt() function in C?
int
float
double
long
8
What is the output of ceil(3.2)?
9 What is the default storage class for a local variable declared inside a function block?
static
extern
auto
register
10
Where are auto variables stored in memory?
11 Which storage class allows a local variable to retain its value between multiple function calls?
auto
extern
register
static
12
What is the default initial value of an uninitialized variable with the static storage class?
13 Which keyword is used to declare a variable that is defined in another file?
global
import
extern
remote
14
A variable declared with the register storage class is stored in:
15
Which of the following operations is NOT allowed on a register variable?
& operator
16 What is the scope of a global variable?
if blocks
17 Consider the equation . Which C function call calculates ?
y = power(x, 3);
y = pow(x, 3);
y = exp(x, 3);
y = x ** 3;
18 What happens if a local variable has the same name as a global variable?
19 In the context of storage classes, what does 'Lifetime' refer to?
20 What is the correct syntax to define a function that takes two integers and returns an integer?
int func(int a, int b) { return a + b; }
void func(int a, int b) { return a + b; }
int func(a, b) { return a + b; }
func(int a, int b) : int { return a + b; }
21 Which of the following creates a 'Stack Overflow' error?
float instead of double
22
What is the initial value of an uninitialized auto variable?
23
Can a static global variable be accessed by other files using extern?
static restricts visibility to the file in which it is declared
24 Which mathematical function is used to calculate the absolute value of an integer?
fabs()
abs()
floor()
mod()
25
What is the result of floor(3.9)?
26
What does the function prototype void test(void); imply?
27 In C, arrays are always passed to functions by:
28 Which storage class is appropriate for a variable that acts as a counter for how many times a specific function is called?
auto
register
static local variable
extern
29 What is 'Tail Recursion'?
30 Which of the following functions does not accept any arguments?
int fun(int n)
void fun(int a, int b)
int fun(void)
int fun(n)
31
If you do not specify a storage class, and the variable is declared inside main(), it is treated as:
static
global
auto
extern
32
What is the return type of fmod(double x, double y)?
int
double
void
long
33
Consider void swap(int a, int b) { int t=a; a=b; b=t; }. If called as swap(x,y), will x and y change in the caller?
swap is a keyword
34 How do you define a function that accepts an array of integers as a parameter?
void func(int arr)
void func(int arr[])
void func(array int)
void func(int [10] arr)
35 Which mathematical function computes the base-10 logarithm?
log()
ln()
log10()
exp()
36 What is 'Scope' in C programming?
37 Recursive functions are generally:
38
What output does the following snippet produce? printf("%f", fabs(-5.5));
39 To modify the actual arguments in the calling function, parameters must be passed by:
40
If a function foo calls function bar, and bar calls foo, this is known as:
41 Which of the following is true about Formal Parameters?
42
The storage class extern is effectively the default for:
43 Which function computes ?
exp(x, y)
pow(x, y)
power(x, y)
sqrt(x, y)
44
Can main() function be called recursively?
45 Which storage class specifies that a variable should be stored in the CPU for faster access?
auto
extern
register
static
46 Which of the following is a valid function prototype?
int sum(int x, int y)
int sum(int x, int y);
sum(int x, int y);
void sum{int x, int y}
47
What is the scope of a variable declared inside a for loop (e.g., for(int i=0;...) in C99 standard?
48 What happens if a recursive function has a base case but the recursive step does not move towards it?
49 Which storage class is stored in the Data Segment of memory?
auto
register
static
typedef
50
The trigonometric function sin(x) expects the angle to be in: