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.361Medium

A program uses fprintf() to write 1000 integers to a file but doesn't call fclose(). What could happen?

Q.362Medium

A binary file contains 500 structures of size 32 bytes each. To skip the first 10 structures and read the 11th one, which fseek() call is correct?

Q.363Medium

Which of the following modes will truncate an existing file?

Q.364Medium

A program reads a CSV file with fgets() storing data in a 256-byte buffer. Some lines exceed 255 characters. How should this be handled?

Q.365Medium

What does fflush(fp) do when fp is a file pointer?

Q.366Medium

In a file opened in "a+" mode, where does the file pointer initially point?

Q.367Medium

Which mode allows both reading and appending without truncating existing content?

Q.368Medium

What does the function ftell(fp) return in file handling?

Q.369Medium

Which of the following correctly reads a string from file with size limit?

Q.370Medium

A program needs to update specific bytes in the middle of a file without affecting other data. Which approach is most suitable?

Q.371Medium

What is the difference between 'rb' and 'r' modes when opening a file?

Q.372Medium

In a file opened with 'rb+' mode, what operations can be performed?

Q.373Medium

A program reads structured data: fread(ptr, sizeof(struct), count, fp). If fread() returns a value less than 'count', what could be the reason?

Q.374Medium

In competitive exam file handling questions, if fseek() is called with SEEK_CUR, what does it indicate?

Q.375Medium

A C program must securely close a file and handle potential errors. What is the best approach?

Q.376Medium

A program needs to append 500 integers to an existing binary file. Which combination is correct?

Q.377Medium

What happens if you call fclose() on an already closed file pointer?

Q.378Medium

A program reads struct records using fread(). After reading 100 records of 64 bytes each, what is the total bytes read if successful?

Q.379Medium

Which statement correctly counts non-comment lines in a text file?

Q.380Medium

In a program processing a CSV file, what is the most robust approach for reading variable-length lines?