TCS File Handling Questions Quiz-1

Question 1

Time: 00:00:00
The value of EOF is _____

-1

-1

2

2

1

1

10

10

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 2

Time: 00:00:00
Which of the following true about FILE *fp

FILE is a keyword in C for representing files and fp is a variable of FILE type.

FILE is a keyword in C for representing files and fp is a variable of FILE type.

FILE is a structure and fp is a pointer to the structure of FILE type

FILE is a structure and fp is a pointer to the structure of FILE type

FILE is a stream

FILE is a stream

FILE is a buffered stream

FILE is a buffered stream

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

typedef struct { int level; /* fill/empty level of buffer */ unsigned flags; /* File status flags */ char fd; /* File descriptor */ unsigned char hold; /* Ungetc char if no buffer */ int bsize; /* Buffer size */ unsigned char *buffer; /* Data transfer buffer */ unsigned char *curp; /* Current active pointer */ unsigned istemp; /* Temporary file indicator */ short token; /* Used for validity checking */ }FILE;

Question 3

Time: 00:00:00
The first and second arguments of fopen are ______

A character string containing the name of the file & the second argument is the mode

A character string containing the name of the file & the second argument is the mode

A character string containing the name of the user & the second argument is the mode

A character string containing the name of the user & the second argument is the mode

A character string containing file poniter & the second argument is the mode

A character string containing file poniter & the second argument is the mode

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

a) A character string containing the name of the file & the second argument is the mode

Question 4

Time: 00:00:00
If there is any error while opening a file, fopen will return

Nothing

Nothing

EOF

EOF

NULL

NULL

Depends on compiler

Depends on compiler

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

depends on the compiler

PrepInsta User

depends on the compiler

PrepInsta User

c) NULL

PrepInsta User

null

Question 5

Time: 00:00:00
fseek() should be preferred over rewind() mainly because

rewind() doesn’t work for empty files

rewind() doesn’t work for empty files

rewind() may fail for large files

rewind() may fail for large files

In rewind, there is no way to check if the operations completed successfully

In rewind, there is no way to check if the operations completed successfully

All of the above

All of the above

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

Explanation: The rewind function sets the file position indicator for the stream pointed to by stream to the beginning of the file.

Question 6

Time: 00:00:00
FILE is of type ______

int type

int type

char * type

char * type

struct type

struct type

None of the mentioned

None of the mentioned

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

Explanation: It is what is typically termed an opaque data type, meaning it\'s typically declared as a simple structure, and then internally in the OS libraries the FILE pointer is cast to the actual date-type of the data-structure that the OS will use access data from a file. A lot of these details are system-specific though, so depending on the OS, the definition may differ.

PrepInsta User

structure obviously :)

Question 7

Time: 00:00:00
FILE reserved word is

A structure tag declared in stdio.h

A structure tag declared in stdio.h

One of the basic datatypes in c

One of the basic datatypes in c

Pointer to the structure defined in stdio.h

Pointer to the structure defined in stdio.h

It is a type name defined in stdio.h

It is a type name defined in stdio.h

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

D

PrepInsta User

Explanation: It is a type name defined in stdio.h

Question 8

Time: 00:00:00
getc() returns EOF when

End of files is reached

End of files is reached

When getc() fails to read a character

When getc() fails to read a character

Both of the above —

Both of the above —

None of the above

None of the above

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 9

Time: 00:00:00
Which of the following functions from “stdio.h” can be used in place of printf()?

fputs() with FILE stream as stdout.

fputs() with FILE stream as stdout.

fprintf() with FILE stream as stdout.

fprintf() with FILE stream as stdout.

fwrite() with FILE stream as stdout.

fwrite() with FILE stream as stdout.

All of the above three – a, b and c.

All of the above three – a, b and c.

In “stdio.h”, there’s no other equivalent function of printf()

In “stdio.h”, there’s no other equivalent function of printf()

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

Question 10

Time: 00:00:00
fputs adds newline character

True

True

False

False

Depends on the standard

Depends on the standard

Undefined behaviour

Undefined behaviour

Once you attempt the question then PrepInsta explanation will be displayed.

Please login to submit your explanation

PrepInsta User

true

PrepInsta User

a) True

["0","40","60","80","100"]
["Need more practice!","Keep trying!","Not bad!","Good work!","Perfect!"]

Buy TCS Prog. Logic (C MCQ) Paid Materials

Join TCS Online Classes

Personalized Analytics only Availble for Logged in users

Analytics below shows your performance in various Mocks on PrepInsta

Your average Analytics for this Quiz

Rank

-

Percentile

0%

Get over 200+ Courses under One Subscription

mute

Don’t settle Learn from the Best with PrepInsta Prime Subscription

Learn from Top 1%

One Subscription, For Everything

The new cool way of learning and upskilling -

Limitless Learning

One Subscription access everything

Job Assistance

Get Access to PrepInsta Prime

Top Faculty

from FAANG/IITs/TOP MNC's

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others.

Comments