Exercise: Input Output

Questions for: Input Output

Can we specify a variable filed width in a scanf() format string?
A:
Yes
B:
No
C:
D:
Answer: B
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.
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
C:
D:
Answer: A
It prints n=    5
A file written in text mode can be read back correctly in binary mode.
A:
Yes
B:
No
C:
D:
Answer: B

If you write a file in text mode and then read it back in binary mode, the translations performed in text mode may result in the file's contents being misinterpreted or incorrectly read in binary mode. For consistent behavior, a file should be read and written in the same mode (both text or both binary).

stderr, stdin, stdout are FILE pointers
A:
Yes
B:
No
C:
D:
Answer: A

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;

In a call to printf() function the format specifier %b can be used to print binary equivalent of an integer.
A:
True
B:
False
C:
D:
Answer: B

There is no format specifier named %b in c.

Ad Slot (Above Pagination)
Quiz