This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Standard Input & Output – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. Which is not true about function tolower?
a) The function tolower is defined in <ctype.h>
b) Converts an uppercase letter to lowercase
c) Returns other characters untouched
d) None of the mentioned
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
char c = '�';
putchar(c);
}
a) Compile time error
b) Nothing
c) 0
d) Undefined behaviour
View Answer
Explanation: None.
3. putchar(c) function/macro always outputs character c to the __________
a) screen
b) standard output
c) depends on the compiler
d) depends on the standard
View Answer
Explanation: None.
4. What will be the output of the following C code if following commands are used to run (considering myfile exists)?
gcc -otest test.c
./test < myfile
#include <stdio.h>
int main()
{
char c = 'd';
putchar(c);
}
a) Compile time error (after first command)
b) d in the myfile file
c) d on the screen
d) Undefined behaviour
View Answer
Explanation: None.
5. What will be the output of the following C code if following commands are used to run (considering myfile exists)?
gcc -otest test.c
./test > myfile
#include <stdio.h>
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
a) d 2 in myfile
b) d 1 in myfile
c) d in myfile and 1 in screen
d) d in myfile and 2 in screen
View Answer
Explanation: None.
6. What will be the output of the following C code if following commands are used to run and if myfile does not exist?
gcc -o test test.c
./test > myfile
#include <stdio.h>
int main(int argc, char **argv)
{
char c = 'd';
putchar(c);
printf(" %d\n", argc);
}
a) d 2 in myfile
b) d 1 in myfile
c) Depends on the system
d) Depends on the standard
View Answer
Explanation: None.
7. The statement prog < infile causes _________
a) prog to read characters from infile
b) prog to write characters to infile
c) infile to read characters from prog instead
d) nothing
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Practice BCA MCQs
- Check Computer Science Books
- Apply for Computer Science Internship
- Watch Advanced C Programming Videos
- Apply for C Internship