Unit 3 - Practice Quiz
CSE101
1 What is a function prototype in C?
2
In the function definition int add(int a, int b), what are a and b called?
3 If a function does not return a value, its return type must be declared as:
int
null
void
empty
4 Which of the following statements is true regarding the default return type of a function in C (C89 standard)?
void.
float.
int.
5 What happens when a function is called by value?
6 Which operator is required to pass the address of a variable to a function in a 'call by reference' context?
* (Asterisk)
& (Ampersand)
-> (Arrow)
. (Dot)
7
Consider the function prototype: void swap(int *x, int *y);. This function uses:
8
Which header file must be included to use mathematical functions like sqrt() and pow()?
<stdio.h>
<stdlib.h>
<math.h>
<conio.h>
9
What is the return type of the standard library function sqrt(double x)?
int
float
double
void
10
What does the function ceil(3.2) return?
11 What is a recursive function?
12 What is the essential condition required to stop infinite recursion?
13 If a recursive function does not have a base case, what runtime error is likely to occur?
14 Which mathematical sequence is classically calculated using recursion where ?
15 What is the scope of a local variable?
main function.
16 Where are global variables declared?
main function.
17 What happens if a local variable has the same name as a global variable?
18 Which of the following is NOT a storage class specifier in C?
auto
static
mutable
register
19
What is the default storage class for a variable declared inside a function (e.g., int x;)?
extern
static
register
auto
20
Where are variables with the auto storage class stored?
21
What is the default initial value of an uninitialized auto variable?
22 Which storage class requests the compiler to store the variable in a CPU register for faster access?
fast
static
register
auto
23
Which operator cannot be applied to a variable with the register storage class?
++)
=)
&)
+)
24
What is the lifetime of a static local variable?
25
What is the default initial value of a static variable if not explicitly initialized?
26
When is a static variable initialized?
27 Which keyword is used to declare a variable that is defined in a different file?
global
import
extern
static
28
A global variable declared with the static keyword has:
29
What does the function floor(4.9) return?
30 What is the correct syntax to define a function that takes an integer array as an argument?
void func(int arr[])
void func(int arr)
void func(array int)
void func(int [arr])
31
In the expression result = pow(a, b);, what is the mathematical equivalent?
32 What is the scope of a function parameter?
33 Which storage class is stored in the Data Segment of memory?
auto
register
static and Global variables
34
Consider int f(int n) { if(n==1) return 1; else return n*f(n-1); }. What does this calculate?
35
If you modify a static variable inside a function, what happens to its value when the function is called again?
36
What does the abs() function return?
37 Can a function definition be nested inside another function definition in standard C?
static.
void.
38
Which call is correct for a function declared as void compute(float *ptr, int val);?
compute(5.5, 10);
float f; compute(f, 10);
float f; compute(&f, 10);
compute(*f, 10);
39 What is 'Tail Recursion'?
40 Which of the following functions generates a random number?
srand()
rand()
random()
generate()
41 When passing an array to a function, what is actually passed?
42
Which storage class specifier allows a global variable to be accessed by other files using extern?
static
auto
register
43
What is the mathematical function fmod(x, y) used for?
44
In a function signature int max(int, int);, the names of the parameters are:
45 What is the limit of the number of arguments a function can take?
46
If you define a local variable auto int x; inside a loop, what happens to x in each iteration?
47 Which keyword is used to return a value from a function?
send
break
return
exit
48
What does extern int count; do?
count.
count to zero.
count is defined elsewhere, without allocating memory.
49 Direct recursion is when function A calls function A. Indirect recursion is when:
50
What is the return type of malloc() function?
int*
char*
void*
null