C Programming Questions and Answers – Standard Input & Output – 2

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

Answer: d
Explanation: None.

2. What will be the output of the following C code?

advertisement
advertisement
  1.     #include <stdio.h>
  2.     int main()
  3.     {
  4.         char c = '�';
  5.         putchar(c);
  6.     }

a) Compile time error
b) Nothing
c) 0
d) Undefined behaviour
View Answer

Answer: b
Explanation: None.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

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

Answer: b
Explanation: None.

4. What will be the output of the following C code if following commands are used to run (considering myfile exists)?

advertisement
  1.     gcc -otest test.c
  2.     ./test < myfile
  3.  
  4.     #include <stdio.h>
  5.     int main()
  6.     {
  7.         char c = 'd';
  8.         putchar(c);
  9.     }

a) Compile time error (after first command)
b) d in the myfile file
c) d on the screen
d) Undefined behaviour
View Answer

Answer: c
Explanation: None.
advertisement

5. What will be the output of the following C code if following commands are used to run (considering myfile exists)?

  1.     gcc -otest test.c
  2.     ./test > myfile
  3.  
  4.      #include <stdio.h>
  5.     int main(int argc, char **argv)
  6.     {
  7.         char c = 'd';
  8.         putchar(c);
  9.         printf(" %d\n", argc);
  10.     }

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

Answer: b
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?

  1.     gcc -o test test.c
  2.     ./test > myfile
  3.  
  4.     #include <stdio.h>
  5.     int main(int argc, char **argv)
  6.     {
  7.         char c = 'd';
  8.         putchar(c);
  9.         printf(" %d\n", argc);
  10.     }

a) d 2 in myfile
b) d 1 in myfile
c) Depends on the system
d) Depends on the standard
View Answer

Answer: b
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

Answer: a
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.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.