Home Subjects C Programming

C Programming

C language from basics to advanced placement prep

303 Q 10 Topics Take Test
Advertisement
Difficulty: All Easy Medium Hard 81–90 of 303
Topics in C Programming
Q.81 Easy File Handling
Which function is used to close a file in C?
A fclose()
B close_file()
C file_close()
D closefile()
Correct Answer:  A. fclose()
EXPLANATION

fclose() is the standard function to close an opened file stream. It returns 0 on success and EOF on error.

Take Test
Q.82 Easy File Handling
What does the mode 'rb' mean in fopen()?
A Read in binary mode
B Read and backup mode
C Rewrite and binary mode
D Remove and backup mode
Correct Answer:  A. Read in binary mode
EXPLANATION

'rb' mode opens a file for reading in binary format. Binary mode reads the exact bytes without any text conversion.

Take Test
Q.83 Easy File Handling
Which function is used to open a file in C?
A fopen()
B open_file()
C file_open()
D openfile()
Correct Answer:  A. fopen()
EXPLANATION

fopen() is the standard C library function used to open a file. It takes two arguments: filename and mode.

Take Test
Given a structure with array members, how would you efficiently pass it to a function to avoid copying overhead?
A Pass by value directly
B Pass a pointer to the structure
C Use typedef with the structure
D Convert to union before passing
Correct Answer:  B. Pass a pointer to the structure
EXPLANATION

Passing a pointer to the structure avoids copying the entire structure in memory, which is especially important for large structures with array members. This improves performance significantly.

Take Test
struct Node { int data; struct Node *next; }; This is an example of which design pattern?
A Recursive structure
B Self-referential structure
C Circular structure
D Polymorphic structure
Correct Answer:  B. Self-referential structure
EXPLANATION

A self-referential structure contains a pointer to its own type. This is the fundamental building block for creating linked lists, trees, and other dynamic data structures.

Take Test
What is the key difference between a structure and a union in C?
A Union allocates memory for all members simultaneously, structure allocates for each member separately
B Structure allocates memory equal to sum of all members, union allocates memory equal to the largest member
C Union can have function pointers, structure cannot
D Structure supports inheritance, union does not
Correct Answer:  B. Structure allocates memory equal to sum of all members, union allocates memory equal to the largest member
EXPLANATION

In structures, memory is allocated for each member independently. In unions, all members share the same memory location, so total memory allocated equals the size of the largest member.

Take Test
In the context of structures, what does 'self-referential' mean?
A A structure that contains a member of the same structure type
B A structure that refers to global variables
C A structure that contains only pointers
D A structure defined within another structure
Correct Answer:  A. A structure that contains a member of the same structure type
EXPLANATION

Self-referential structures contain pointers to their own type, enabling dynamic data structures like linked lists and trees.

Take Test
Given: struct Node { int data; struct Node *next; }; This represents which data structure concept?
A Binary Tree node
B Singly Linked List node
C Graph adjacency node
D Hash table bucket
Correct Answer:  B. Singly Linked List node
EXPLANATION

A self-referential structure with a single pointer member is the fundamental building block of a singly linked list.

Take Test
In C, what does the 'typedef' keyword do when used with structures?
A Creates a new data type that is an alias for the structure
B Allocates memory for the structure
C Makes the structure accessible globally only
D Prevents the structure from being modified
Correct Answer:  A. Creates a new data type that is an alias for the structure
EXPLANATION

typedef creates an alias, allowing you to use the structure name directly without using 'struct' keyword.

Take Test
Which of the following correctly demonstrates accessing a member of a pointer to a structure?
A ptr.member
B (*ptr).member
C **ptr.member
D ptr->member->member
Correct Answer:  B. (*ptr).member
EXPLANATION

Both (*ptr).member and ptr->member are valid. Option B uses explicit dereferencing, while the arrow operator is syntactic sugar for this.

Take Test
IGET
iget AI
Online · Ask anything about exams
Hi! 👋 I'm your iget AI assistant.

Ask me anything about exam prep, MCQ solutions, study tips, or strategies! 🎯
UPSC strategy SSC CGL syllabus Improve aptitude NEET Biology tips