C Programming :: File Input/Output

Home > C Programming > File Input/Output > General Questions

1 / 12

 What is the output of the following 'C' program ?

#include
void main()
{
FILE *ptr;
char i;
ptr=fopen("abc","r");
while((i=fgets(ptr))!=EOF)
printf("%c",i);
}

Answer: Option A

Explanation:

The condition is checked against EOF, it should be checked against NULL.

Workspace


Tags:  No Tags on this question yet!

2 / 12

 If the content of a file (input) is abc def. What will be the value of input and ch?.

#include
char input[100],ch;
void main(void)
{
FILE *fp;
fp = fopen("input","rb");
fscanf(fp, "%s" ,&input);
fscanf(fp, "%c" ,&ch);
printf("%s %c", input, ch);
}

Answer: Option C

Explanation:

It will not scan anything after a space is encountered. 

Workspace


Tags:  No Tags on this question yet!

3 / 12

 If a file contains the line "I am an Indian\r\n" then on reading this line into the array str using fgets().
what would str contain?

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

4 / 12

 In the following 'C' code, fp points to

#include
void main()
{
FILE* fp;
fp = fopen ("trial", "r");
}

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

5 / 12

 In the following statement, the variable fpt is

fprintf(fpt, "%n", i);

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

Answer: Option B

Explanation:

This is because here 'w' means it truncate file to zero length or create text file for writing. The stream is positioned at the beginning of the file. But, it is null hence, the file "sample" could not be created for writing.

Workspace


Tags:  No Tags on this question yet!

Answer: Option B

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

9 / 12

 Which of the following is/are advantages of cellular partitioned structure:

Answer: Option A

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!

Answer: Option C

Explanation:

Here is no explanation for this answer

Workspace


Tags:  No Tags on this question yet!