You are developing a large-scale simulation that runs for a long duration. After running for a few hours, you notice the program slows down significantly. What could be a likely reason for this behavior?

  • CPU Overheating
  • Memory Leak
  • Network Latency
  • Software Bug
A memory leak is a common reason for slowing down a long-running program. It occurs when memory is allocated but not released, leading to resource exhaustion and slow performance.

You need to implement a function that modifies multiple variables of different data types. What concept related to pointers would you use?

  • Arrays of pointers
  • Function pointers
  • Generic pointers
  • Typecasting pointers
Typecasting pointers would allow you to change the data type of a pointer to manipulate variables of different data types in a single function.

How can you specify the starting value of an enumeration in C?

  • By initializing the first element of the enumeration with a value
  • By using the sizeof operator
  • It's not possible to specify the starting value
  • Using the #define directive
In C, you can specify the starting value of an enumeration by initializing the first element with a value. This value will be the starting point, and subsequent elements will increment from there.

A ________ pointer is a pointer that still points to a memory location that has been deallocated.

  • Dangling
  • Dynamic
  • Null
  • Static
A "dangling" pointer is a pointer that continues to reference a memory location that has been deallocated. This can lead to unexpected behavior and should be avoided.

A structure containing an instance of another structure within it is known as a ________ structure.

  • Arrayed
  • Complex
  • Inherited
  • Nested
When a structure contains an instance of another structure within it, it is referred to as a nested structure.

In C, to ensure that there are no errors while writing to a file, you should check the return value of the ________ function.

  • fclose
  • ferror
  • feof
  • fflush
To ensure error-free file writing, you should check the return value of the ferror function, making option b) "ferror" the correct choice.

What is the behavior of a union when different data types of different sizes are used?

  • It leads to a runtime error
  • It results in a compilation error
  • The union will have the size of the largest data type
  • The union will have the size of the smallest data type
In C, when different data types of different sizes are used in a union, the union will have the size of the largest data type. This allows you to store data of different types in the same memory location.

What is the purpose of the feof function in file handling in C?

  • It checks if the file pointer is at the beginning.
  • It checks if the end-of-file indicator is set.
  • It returns the size of the file.
  • It verifies if the file is open for editing.
The correct option is It checks if the end-of-file indicator is set. The feof function is used to determine if the end-of-file indicator has been set for a stream, helping to identify whether the end of the file has been reached during file operations in C.

What is the main limitation of using typedef to create an alias for a data type?

  • It adds flexibility to data types
  • It can lead to confusion with multiple typedefs
  • It enforces strong data typing
  • It increases code readability
The main limitation of using typedef to create an alias is that it can lead to confusion when multiple typedefs are used for the same base type.

What type of variable is one that is declared outside any function and is available throughout the program?

  • Constant variable
  • Global variable
  • Local variable
  • Static variable
A global variable is declared outside any function and is accessible throughout the program, making it available for all functions to use.