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

Which function is used to read a string from a file, including whitespace characters, up to a maximum length?

Q.22Medium

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

Q.23Medium

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

Q.24Medium

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

Q.25Medium

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

Q.26Medium

What does ftell() function return?

Q.27Medium

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

Q.28Medium

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

Q.29Medium

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

Q.30Medium

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

Q.31Hard

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

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

Q.33Hard

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

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

Q.35Easy

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

Q.36Easy

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

Q.37Easy

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

Q.38Easy

What does the fclose() function do?

Q.39Medium

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

Q.40Easy

Which function writes formatted output to a file?