Q5.What is the correct return type of the fopen() function in C?
a) char
b) FILE *
c) int
d) void
Answer: b) FILE *
Q6._____ the function is used to read a character from a file in C?
a) readchar()
b) fread()
c) read()
d) getc()
Answer: d) getc()
Q7.Which one of the following function is used to write a character to a file in C?
a) fwrite()
b) write()
c) putc()
d) writechar()
Answer: c) putc()
Q8.Choose correct syntax to open file in write mode.
a) FILE *fptr = fopen("my_file.txt", "r");
b) FILE * fptr = fopen("my_file.txt", "wb");
c) FILE * fptr = fopen("my_file.txt", "a");
d) FILE * fptr = fopen("my_file.txt", "w");
Answer: d) FILE * fptr = fopen("my_file.txt", "w");
Q9.Which one of the following function is used to read a line from any file?
a) fgets() function.
b) readLine() function.
c) by using readline() function.
d) using readstring() function.
Answer: a) fgets() function.
Q10.which function in c you will use to write string in a file?
a) putstring()
b) fwrite()
c) fputs()
d) writeString()
Answer: c) fputs()
Q11.How will you move the file pointer to a specific location in a file in C?
a) seek()
b) fseek()
c) move()
d) position()
Answer: b) fseek()
Q12.which of the following function you use to check the end of file?
a) Use the fseek() function
b) Use the feof() function
c) Use checking the file size
d) Use the read() function
Answer: d) Use the feof() function
Q13.how do you delete a file in C?
a) delete()
b) remove()
c) deletefile()
d) erase()
Answer: b) remove()
Q14.Which mode should I use when opening a file to read a binary file in C?
a) "r"
b) "rb"
c) "a"
d) "w"
Answer: b) "rb"
Q15.Which function is used to rename file in C?
a) use rename()
b) with help of renamefile()
c) by using moveto()
d) movefile() function
Answer: a) use rename()
Q16.Which function in C is used to check for the existence of a file?
a) the fileexists() function
b) a checkfile() function
c) use fileexist() function
d) using access() function
Answer: d) using access() function
Q17.What is the maximum file size that can be handled in C for 32-bit systems?
a) 2 GB
b) 4 GB
c) 8 GB
d) 16 GB
Answer: a) 2 GB
Q18._____ function is used to write contents or data to a binary file in C?
a) write()
b) fwrite()
c) putdata()
d) writebinary()
Answer: b) fwrite()
Q19.What is the function of getting the current file pointer position in C?
a) getpos()
b) fseek()
c) ftell()
d) tellpos()
Answer: c) ftell()
Q20.With the help of _________ function data is read from a binary file in C?
a) read()
b) fread()
c) getdata()
d) readbinary()
Answer: b) fread()
Q21.How to create a new directory in C?
a) mkdir()
b) createdir()
c) newdir()
d) makedir()
Answer: a) mkdir()
Q22.Which function is the use of checking file permissions in C?
a) chmod()
b) checkperm()
c) access()
d) permiss()
Answer: c) access()
Q23.You can use _______ function to check the size of a file in C?
a) size()
b) fsize() function.
c) fseek()
d) ftell()
Answer: c) fseek() and d)ftell()
Q24.What function you use to copy the contents of one file to another in C?
a) cpfile()
b) copyfile()
c) copy()
d) filecopy()
Answer: b) copyfile()
Q25.What is the function of setting the file position pointer to the beginning of a file in C?
a) rewind()
b) resetfile()
c) setpos()
d) reset()
Answer: a) rewind()
Previous Topic:-->>Pointers MCQ. || Next topic:-->>Storge Class MCQ in C.