Yes / No Questions

Question 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;


Question 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.


Question 3 :

Will the following program work?

#include
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


Question 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.