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

Start

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

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;

Start

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

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

Start

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

depends on the compiler

depends on the compiler

c) NULL

null

Start

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

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

Start

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

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.

structure obviously :)

Start

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

D

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

Start

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

Start

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

Start

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

true

a) True

Start

["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%

Completed

0/10

Accuracy

0%

Get Prepinsta Prime

Get all 200+ courses offered by Prepinsta

Never Miss an OffCampus Update

Get OffCampus Updates on Social Media from PrepInsta

Follow us on our Media Handles, we post out OffCampus drives on our Instagram, Telegram, Discord, Whatsdapp etc.

Get Hiring Updates
Amazon,Google,Delottie & 30+companies are hiring ! Get hiring Updates right in your inbox from PrepInsta

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.

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.

Get PrepInsta Prime Subscription

Get access to all the courses that PrepInsta offers, check the out below -

Companies

TCS, Cognizant, Delloite, Infosys, Wipro, CoCubes, KPMG, Amazone, ZS Associates, Accenture, Congnizant & other 50+ companies

Programming

Data Structures, Top 500 Codes, C, C++, Java Python & other 10+ subjects

Skills

Full Stack Web Development, Data Science, Machine Learning, AWS Cloud, & other 10+ skills and 20+ projects

Comments