C Programming - Input / Output

1. 

stderr, stdin, stdout are FILE pointers

A. Yes
B. No

Answer: Option A

Explanation:

Yes, these will be declared like

The corresponding stdio.h variable is FILE* stdin;

The corresponding stdio.h variable is FILE* stdout;

The corresponding stdio.h variable is FILE* stderr;


2. 

A file written in text mode can be read back in binary mode.

A. Yes
B. No

Answer: Option B

Explanation:

The difference is that text files contain lines (or records) of text and each of these has an end-of-line marker automatically appended to the end of it whenever you indicate that you have reached the end of a line.

Binary files are not broken up into separate lines or records so the end-of line marker is not written when writing to a binary file.

So, we cannot read the correct the data in binary mode.


3. 

Will the following program work?

#include<stdio.h>

int main()
{
    int n=5;
    printf("n=%*d\n", n, n);
    return 0;
}

A. Yes
B. No

Answer: Option A

Explanation:

It prints n=    5

4. 

Can we specify a variable filed width in a scanf() format string?

A. Yes
B. No

Answer: Option B

Explanation:

In scanf() a * in a format string after a % sign is used for the suppression of assignment. That is, the current input field is scanned but not stored.