C Programming MCQ Hardest Trivia Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Sandesh
S
Sandesh
Community Contributor
Quizzes Created: 1 | Total Attempts: 944
| Attempts: 944 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Which of the following operations can be performed on the file "NOTES.TXT" using the below code?

Explanation

The code provided does not explicitly mention any specific operation being performed on the file "NOTES.TXT". However, the code suggests that it is capable of both reading and writing to the file. Therefore, the correct answer is "Read and Write".

Submit
Please wait...
About This Quiz
C Programming MCQ Hardest Trivia Quiz - Quiz

Dive into the complexities of C programming with this challenging trivia quiz. Test your knowledge on file handling, pointer usage, and correct syntax in C. Perfect for advanced learners looking to sharpen their programming skills and understand intricate details of C language.

Personalize your quiz and earn a certificate with your name on it!
2. What does fp point to in the program ?

Explanation

The correct answer is a structure which contains a char pointer which points to the first character of a file. This is because in most programming languages, when we open a file, we use a file pointer (fp) to keep track of the file's location. The file pointer is a structure that contains information about the file, including a char pointer that points to the first character in the file. Therefore, fp points to a structure which contains a char pointer pointing to the first character of the file.

Submit
3. To scan a and b given below, which of the following scanf() statement will you use?

Explanation

The correct answer is scanf("%f %lf", &a, &b); because the format specifier %f is used to scan a float value, and the format specifier %lf is used to scan a double value. Since the variables a and b are of type float and double respectively, this scanf statement is the correct one to use.

Submit
4. Out of fgets() and gets() which function is safe to use?

Explanation

fgets() is the safer function to use out of fgets() and gets(). The gets() function is considered unsafe because it does not perform any bounds checking on the input, which can lead to buffer overflow vulnerabilities. On the other hand, fgets() allows you to specify the maximum number of characters to read, preventing buffer overflow issues.

Submit
5. What is the purpose of "rb" in fopen() function used below in the code?

Explanation

The purpose of "rb" in the fopen() function is to open the file "source.txt" in binary mode for reading. The "b" in "rb" indicates that the file should be opened in binary mode, which means that the file will be read as a sequence of bytes rather than as text. This is useful when working with files that contain non-textual data, such as images or audio files.

Submit
6. To print out a and b given below, which of the following printf() statement will you use?

Explanation

The correct answer is printf("%f %lf", a, b) because it correctly specifies the format specifiers for the variables a and b. The %f specifier is used for float variables, while the %lf specifier is used for double variables. Therefore, this printf statement will correctly print out the values of a and b. The other printf statements either use incorrect format specifiers or mix up the order of the specifiers, which would result in incorrect output.

Submit
7. Which files will get closed through the fclose() in the following program?

Explanation

The correct answer is "Error in fclose()". This means that there is an error in the fclose() function in the program, and therefore no files will get closed.

Submit
8. On executing the below program what will be the contents of 'target.txt' file if the source file contains a line "To err is human"?

Explanation

The contents of the 'target.txt' file will be "Trh". This is because the program reads the source file and only writes the second and third characters of each line to the target file. In the given source line "To err is human", the second character is 'r' and the third character is 'r', so only "Trh" will be written to the target file.

Submit
9. Consider the following program and what will be content of t?

Explanation

The content of "t" will be the handle associated with the "DUMMY.C" file. This means that "t" will contain the identifier or reference to the file "DUMMY.C", allowing the program to perform operations on that file such as reading or writing data.

Submit
10. In a file contains the line "I am a boy\r\n" then on reading this line into the array str using fgets(). What will str contain?

Explanation

The correct answer is "I am a boy\0". When the line "I am a boy\r" is read into the array using fgets(), it will include the carriage return character '\r' at the end of the string. The '\r' represents a carriage return, which is a control character used to move the cursor to the beginning of the line. The '\0' represents the null character, which is used to terminate the string. Therefore, the resulting string in the array will be "I am a boy\0".

Submit
View My Results

Quiz Review Timeline (Updated): Mar 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • May 12, 2016
    Quiz Created by
    Sandesh
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Which of the following operations can be performed on the file...
What does fp point to in the program ?
To scan a and b given below, which of the...
Out of fgets() and gets() which function is safe...
What is the purpose...
To print out a and b given below, which of the...
Which files will get closed through the fclose() in the...
On executing the below program what will be the contents of...
Consider the following program and what will be content of t?
In a file contains the line "I am a boy\r\n" then on reading...
Alert!

Advertisement