The keyword ________ is used to define a structure in C.
- allocate
- define
- struct
- typedef
In C, the "struct" keyword is used to define a structure. Structures are used to group related data members under a single name.
The function ________ is used to move the file pointer to a specific position in the file.
- file_seek()
- fseek()
- move_pointer()
- position_file()
In file handling, fseek() is employed to move the file pointer to a specified position within the file. This is crucial for navigating and accessing specific parts of a file during read or write operations.
You're developing a program to calculate the area of a circle. What data type would be most suitable to store the radius, considering it can be a fractional value?
- char
- double
- float
- int
To store the radius of a circle with fractional values, the most suitable data type in C is 'double' as it offers high precision for such calculations.
What is the purpose of using random access in file handling?
- To access files in a random order.
- To create files with random names.
- To generate random numbers for file operations.
- To perform direct read/write operations at any position within the file.
The purpose of using random access in file handling is to perform direct read and write operations at any position within the file. Random access allows you to jump to a specific location in a file and read or write data without having to sequentially process the entire file. It's especially useful for large files or databases.
In a scientific computation program, you need to represent a matrix of real numbers. What kind of array would be suitable for this purpose?
- 1D Array
- 2D Array
- Binary Tree
- Dynamic Array (ArrayList)
A 2D array is suitable for representing a matrix of real numbers as it offers a grid-like structure to store rows and columns of values.
In C, what is the result of the expression (5 & 3)?
- 0
- 1
- 3
- 5
In C, the '&' operator is the bitwise AND operator. When you perform (5 & 3), it bitwise ANDs the binary representation of 5 (0101) and 3 (0011). The result is 0001, which is 1 in decimal.
You are tasked with optimizing a C program that manipulates large strings. What standard library functions might be critical to review for potential performance bottlenecks?
- getchar() and putchar()
- malloc() and free()
- printf() and scanf()
- strlen() and strcat()
When optimizing a C program that manipulates large strings, functions like strlen() and strcat() should be reviewed for potential performance bottlenecks as they involve string manipulation and can be resource-intensive.
How does the 'register' keyword affect the storage of a variable in a C program?
- It's allocated in a CPU register
- It's allocated in the data segment
- It's allocated in the heap
- It's allocated in the stack
The 'register' keyword suggests to the compiler to store the variable in a CPU register, which can lead to faster access. However, it's just a hint, and the compiler may choose to ignore it.
An array of structures in C allows you to store multiple records, where each record can have ________ of different data types.
- Elements
- Fields
- Files
- Functions
An array of structures allows you to store multiple records, where each record can have fields of different data types. Fields represent the individual members of each structure.
In C programming, what is tail recursion?
- A recursion that involves a loop
- A recursion with a base case at the beginning
- A recursion with a base case at the end
- A recursion with no base case
Tail recursion in C is a type of recursion where the base case is located at the end of the recursive function. This means that the recursive call is the last operation in the function, making it more efficient and easier for the compiler to optimize.