C Programming Multiple Choice Questions and Answers on Standard Input & Output Functions for Freshers

1. Which among the following is odd one out?

a) printf
b) fprintf
c) putchar
d) scanf
Answer: d
2. For a typical program, the input is taken using

a) scanf
b) Files
c) Command-line
d) All of the mentioned
Answer: d
3. What does the following command line signify?
    prog1|prog2

a) It runs prog1 first, prog2 second
b) It runs prog2 first, prog1 second
c) It runs both the programs, pipes output of prog1 to input of prog2
d) It runs both the programs, pipes output of prog2 to input of prog1
Answer: c
4. What is the default return-type of getchar()?

a) char
b) int
C. char *
D. reading character doesn’t require a return-type
Answer: b
5. The value of EOF is_____

a) -1
b) 0
c) 1
d) 10
Answer: a
6. What is the use of getchar()?

a) The next input character each time it is called
b) EOF when it encounters end of file
c) The next input character each time it is called
EOF when it encounters end of file
d) None of the mentioned
Answer: c
7. Which is true?

a) The symbolic constant EOF is defined in
b) The value is -1
c) The symbolic constant EOF is defined in & value is -1
d) Only value is -1
Answer: c
8. What is the return value of putchar()?

a) The character written
b) EOF if an error occurs
c) Nothing
d) Both character written & EOF if an error occurs
Answer: d
9. Which is true about function tolower?

a) The function tolower is defined in 
b) Converts an upper case letter to lower case
c) returns other characters untouched
d) None of the mentioned
Answer: d
10. What is the output of this C code?
  1.     #include 
  2.     int main()
  3.     {
  4.         char c = '�';
  5.         putchar(c);
  6.     }
a) Compile time error
b) Nothing
c) 0
d) Undefined behaviour
Answer: b
11. 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
Answer: b
12. What is the output of this C code if
    following commands are used to run(considering myfile exists)?
    gcc -otest test.c
    ./test < myfile

  1.     #include 
  2.     int main()
  3.     {
  4.         char c = 'd';
  5.         putchar(c);
  6.     }
a) Compile time error (after first command)
b) d in the myfile file
c) d on the screen
d) Undefined behaviour
Answer: c
13. What is the output of this C code if
    following commands are used to run(considering myfile exists)?
    gcc -otest test.c
    ./test > myfile

  1.  #include 
  2.     int main(int argc, char **argv)
  3.     {
  4.         char c = 'd';
  5.         putchar(c);
  6.         printf(" %d\n", argc);
  7.     }
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
Answer: b
14. What is the output of this C code if
    following commands are used to run and if myfile does not exist?
    gcc -o test test.c
    ./test > myfile

  1.  #include 
  2.     int main(int argc, char **argv)
  3.     {
  4.         char c = 'd';
  5.         putchar(c);
  6.         printf(" %d\n", argc);
  7.     }
a) d 2 in myfile
b) d 1 in myfile
c) Depends on the system
d) Depends on the standard
Answer: b
15. The statement prog

a) prog to read characters from infile.
b) prog to write characters to infile.
c) infile to read characters from prog instead.
d) nothing
Answer: a

Related

Multiple Choice Questions 6200828942315246881

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item