C Programming 9

COEP
Lets Crack Online Exam

IT Interview Exam Questions: C Programming 9 (IT Interview Exam Question, IT Campus Placement)

Subject: C Programming 9

Part 9: List for questions and answers of C Language

 

Q1. How is a variable accessed from another file?

a) via the extern specifier

b) via the auto specifier

c) via the global specifier

d) via the pointer specifier

 

Q2. The statement#include”filename.h” is replaced by the constants of “filename.h”

a) before compilation

b) after compilation

c) during execution

d) during typing of the program

 

Q3. Which of the following functions need a filename?

a) fopen

b) fclose

c) fread

d) none of these

 

Q4. What is/are the purpose/purposes of buffer cache?

a) Allocate memory

b) Speed up read/write

c) File system recovery

d) All of the above

 

Q5. What would happen if you create a file stdio.h and use #include “stdio.h” ?

a) The predefined library file will be selected

b) The user-defined library file will be selected

c) Both the files will be included

d) The compiler won’t accept the program

 

Q6. How is search done in #include and #include “somelibrary.h” according to C standard?

a) When former is used, current directory is searched and when latter is used, standard directory is searched

b) When former is used, standard directory is searched and when latter is used, current directory is searched

c) When former is used, search is done in implementation defined manner and when latter is used, current directory is searched

d) For both, search for ‘somelibrary’ is done in implementation-defined places 

 

Q7. The first and second arguments of fopen are?

a) A character string containing the name of the file & the second argument is the mode

b) A character string containing the name of the user & the second argument is the mode

c) A character string containing file poniter & the second argument is the mode

d) None of the mentioned of the mentioned

 

Q8. For binary files, a ___ must be appended to the mode string

a) Nothing

b) “b”

c) “binary”

d) “01?

 

Q9. If there is any error while opening a file, fopen will return?

a) Nothing

b) EOF

c) NULL

d) Depends on compiler

 

Q10. Which is true about getc.getc returns?

a) The next character from the stream referred to by file pointer

b) EOF for end of file or error

c) Both a & b

d) Nothing

 

Q11. When a C program is started, O.S environment is responsible for opening file and providing pointer for that file?

a) Standard input

b) Standard output

c) Standard error

d) All of the mentioned

 

Q12. What is the meant by ‘a’ in the following operation?fp = fopen(“Random.txt”, “a”);

a) Attach

b) Append

c) Apprehend

d) Add 

 

Q13. Which of the following mode argument is used to truncate?

a) a

b) f

c) w

d) t

 

Q14. Which type of files can’t be opened using fopen()?

a) .txt

b) .bin

c) .c

d) None of the mentioned

 

Q15. Which of the following fopen statements are illegal?

a) fp = fopen(“abc.txt”, “r”);

b) fp = fopen(“/home/user1/abc.txt”, “w”);

c) fp = fopen(“abc”, “w”);

d) None of the mentioned

 

Q16. What does the following segment of code do?

fprintf(fp, “Copying!”);

a) It writes “Copying!” into the file pointed by fp

b) It reads “Copying!” from the file and prints on display

c) It writes as well as reads “Copying!” to and from the file and prints it

d) None of the mentioned

 

Q17. FILE reserved word is?

a) A structure tag declared in stdio.h

b) One of the basic datatypes in c

c) Pointer to the structure defined in stdio.h

d) It is a type name defined in stdio.h

 

Q18. stdout, stdin and stderr are?

a) File pointer

b) File desciptors

c) Streams

d) Structure

 

Q19. Which of the following statements about stdout and stderr are true?

a) Same

b) Both connected to screen always

c) Both connected to screen by default

d) stdout is line buffered but stderr is unbuffered 

 

Q20. In a file contains the line “I am a boy\r\n” then on reading this line into the array str using fgets(). What willstr contain?

a) “I am a boy\r\n\0”

b) “I am a boy\r\0”

c) “I am a boy\n\0”

d) “I am a boy” 

 

Part 9: List for questions and answers of C Language

 

Q1. Answer: a

 

Q2. Answer: a

 

Q3. Answer: a

 

Q4. Answer: b

 

Q5. Answer: b

 

Q6. Answer: d

 

Q7. Answer: a

 

Q8. Answer: b

 

Q9. Answer: c

 

Q10. Answer: c

 

Q11. Answer: d

 

Q12. Answer: b

 

Q13. Answer: c

 

Q14. Answer: d

 

Q15. Answer: d

 

Q16. Answer: a

 

Q17. Answer: d

 

Q18. Answer: a

 

Q19. Answer: d


Q20. Answer: c