iGET

C Programming - MCQ Practice Questions

Practice free C Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

978 questions | 100% Free

Q.121Hard

In nested structures with pointers, which access method is correct? struct outer { struct inner *ptr; } *o; Accessing inner's member x:

Q.122Hard

What is the relationship between structure alignment and padding in modern C compilers?

Q.123Hard

In a structure with flexible array members, which statement is INCORRECT? struct FlexArray { int len; int arr[]; };

Q.124Hard

What is the output of the following? struct S { int a:3; int b:3; int c:3; }; printf("%zu", sizeof(struct S));

Q.125Hard

In competitive programming, when should you use union instead of struct?

Q.126Hard

What will be the output of this code? struct X { int a; float b; }; struct Y { struct X x; int c; }; printf("%zu", sizeof(struct Y));

Q.127Hard

In a structure, what does the #pragma pack(1) directive do?

Q.128Hard

If a structure contains a flexible array member, where must it be declared?

Q.129Hard

In competitive programming, when implementing a graph using adjacency lists, which data structure is most suitable?

Q.130Hard

If you have a structure with bit fields, which statement about their behavior is true?

Q.131Hard

What is the output of this complex code? struct S { char c; int i; } s; printf("%lu", sizeof(s));

Q.132Hard

In competitive programming, when you need a structure that can hold either an integer or a floating-point number (but not both simultaneously) in the most memory-efficient way, which should you use?

Q.133Hard

What will be the output of the following code? union Test { int a; char b; }; union Test t; t.a = 65; printf("%d %c", t.a, t.b);

Q.134Hard

In competitive programming for GATE/ISRO 2025, which scenario would union be preferable over structure?

Q.135Hard

Write a code snippet to read 100 bytes from a file. Which is correct?

Q.136Hard

Which of the following correctly implements appending to a file?

Q.137Hard

In a program reading a binary file of 1000 integers, fread() is called as: fread(arr, sizeof(int), 1000, fp). If only 500 integers are present, what will fread() return?

Q.138Hard

Consider using fseek() on a file opened in text mode with SEEK_END and a non-zero offset. What is the standard behavior?

Q.139Hard

A program writes data using fprintf() and later attempts to read it back. However, the read operation fails intermittently. What could be the most likely cause?

Q.140Hard

What is the purpose of using fflush() in file handling, and when is it critical to use it?