iGET

C Programming - MCQ Practice Questions

C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.

972 questions | 100% Free

Q.701Medium

In the context of ferror() function, what does it return?

Q.702Medium

Which mode should be used if you want to read and write to a file without truncating existing content?

Q.703Medium

What is the purpose of the clearerr() function in file handling?

Q.704Medium

Consider a scenario where fopen() fails to open a file. Which of the following is the correct way to handle it?

Q.705Medium

What does ftell() function return?

Q.706Medium

Which of the following fseek() calls will position the file pointer at the end of the file?

Q.707Medium

What is the difference between text mode and binary mode when reading files?

Q.708Medium

Which function is used to read formatted data from a file, similar to scanf() but for files?

Q.709Medium

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

Q.710Hard

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

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

Q.712Hard

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

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

Q.714Easy

Which function is used to determine the current position in a file?

Q.715Easy

What is the correct syntax to open a file named 'data.txt' in read mode?

Q.716Easy

Which mode allows both reading and writing to a file, creating it if it doesn't exist?

Q.717Easy

What does the fclose() function do?

Q.718Medium

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

Q.719Easy

Which function writes formatted output to a file?

Q.720Medium

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