C Programming – Standard Input & Output

C Programming - Standard Input & Output

Question 1
Which among the following is odd one out?
A
printf
B
fprintf
C
putchar
D
scanf
Question 2
 For a typical program, the input is taken using.
A
scanf
B
Files
C
Command-line
D
None of the mentioned
Question 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
Question 4
What is the default return-type of getchar()?
A
char
B
int
C
char *
D
Reading character doesn’t require a return-type
Question 5
The value of EOF is_____.
A
-1
B
0
C
1
D
10
Question 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
Both a & b
D
None of the mentioned
Question 7
Which is true?
A
The symbolic constant EOF is defined in
B
The value is typically -1,
C
Both a & b
D
Either a or b
Question 8
What is the use of putchar()?
A
The character written
B
EOF is an error occurs
C
Nothing
D
Both a & b
Question 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
Question 10
What is the output of this C code?
    #include 
    int main()
    {
    char c = '�';
    putchar(c);
    }
A
Compile time error
B
Nothing
C
0
D
Undefined behaviour
Question 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
Question 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
    #include 
    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
Question 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
    #include 
    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
Question 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
    #include 
    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
Question 15
 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


Check Your Answers:

  1. D
  2. D
  3. C
  4. B
  5. A
  6. C
  7. C
  8. D
  9. D
10. B
11. B
12. C
13. B
14. B
15. A


SHARE

Unknown

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment