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

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

Q.2Hard

Which of the following correctly implements appending to a file?

Q.3Hard

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

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

Q.5Hard

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

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

Q.7Hard

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

Q.8Hard

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

Q.9Hard

A large binary file of 10GB is being processed. Reading entire file into memory is impossible. Which approach is best?

Q.10Hard

How can you determine the size of a file in bytes using standard C functions?

Q.11Hard

When writing binary structures with fwrite(), which precaution is essential for portability across different systems?

Q.12Hard

A program processes a file with multiple reading and writing operations without closing/reopening. What is a potential issue with file buffering?

Q.13Hard

Which scenario would be most problematic when using fprintf() for data that needs exact binary preservation?

Q.14Hard

For reading a configuration file line-by-line where lines may exceed 256 characters, which function is recommended for ISRO/GATE 2024 exams?

Q.15Hard

What does rewind(fp) accomplish compared to fseek(fp, 0, SEEK_SET)?

Q.16Hard

A program processes encrypted binary data with fread(). Why might using 'r' mode instead of 'rb' cause corruption?

Q.17Hard

For competitive exam file validation: A 2GB file must be processed without loading entirely in memory. Which strategy is optimal?

Q.18Hard

When implementing a log file writer with concurrent access, what's the critical issue with standard fopen()?

Q.19Hard

A program reads serialized objects using fread(). What's the primary risk when file format changes between versions?

Q.20Hard

For implementing a file locking mechanism in a competitive exam environment, which approach correctly handles concurrent file access in POSIX systems?