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

What will be the behavior of fgets() when reading from an empty line in a file?

Q.22Medium

A program reads a text file line by line using fgets(). If a line contains more characters than the buffer size, what happens?

Q.23Medium

A file is opened in binary mode. How will fseek() behave differently compared to text mode?

Q.24Medium

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

Q.25Medium

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

Which of the following modes will truncate an existing file?

Q.27Medium

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

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

Q.29Medium

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

Q.30Medium

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

Q.31Medium

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

Q.32Medium

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

Q.33Medium

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

Q.34Medium

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

Q.35Medium

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

Q.36Medium

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

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

Q.38Medium

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

Q.39Medium

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

Q.40Medium

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