iGET

C Programming - MCQ Practice Questions

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

972 questions | 100% Free

Q.121Hard

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

Q.122Hard

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

Q.123Hard

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

Q.124Hard

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.125Hard

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

Q.126Hard

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

Q.127Hard

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

Q.128Hard

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

Q.129Hard

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

Q.130Hard

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.131Hard

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.132Hard

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

Q.133Hard

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

Q.134Hard

Which of the following correctly implements appending to a file?

Q.135Hard

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.136Hard

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

Q.137Hard

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.138Hard

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

Q.139Hard

A program writes binary data using fwrite() but reads it back with fprintf(). What will happen?

Q.140Hard

A program uses fgetc() to read 100,000 characters from a file sequentially. Which alternative would be more efficient?