TCS Previous Year Papers and Study materials

Q.A pointer variable can be
1. Changed within function.
2. Assigned an integer value.
3. None of these
4. Passed to a function as argument.
Correct Op: 4


Q. Which of the following uses structure?
1. Linked Lists
2. Array of structures
3. All of these
4. Binary Tree
Correct Op: 3


Q. Strings are character arrays. The last index of it contains the null-terminated character
1. \t
2. \1
3. \0
4. \n
Correct Op: 3


Q. Which of the following is a collection of different data types?
1. String
2. Structure
3. Array
4. Files
Correct Op: 2


Q. What function should be used to free the memory allocated by calloc() ?
1. free();
2. malloc(variable_name, 0)
3. dealloc();
4. memalloc(variable_name, 0)
Correct Op: 1


Q. In the standard library of C programming language, which of the following
header file is designed for basic mathematical operations?
1. conio.h
2. stdio.h
3. math.h
4. Dos.h
Correct Op: 3


Q. int **ptr; is?
1. Pointer to integer
2. None of these
3. Pointer to pointer
4. Invalid declaration
Correct Op: 3


Q8. Which of the following special symbol allowed in a variable name?
1. (underscore)
2. – (hyphen)
3. | (pipeline)
4. * (asterisk)
Correct Op: 1


Q9. All keywords in C are in
1. Uppercase letters
2. None of these
3. Lowercase letters
4. Camel Case letters
Correct Op: 3

 

Q10. What should the program below print?

1. hello_World
2. ello_World
3. lo_World
4. llo_World

Correct Op: 1

Q: What is the output of this C code?

a) 5 5 5
b) 5 5 junk
c) 5 junk junk
d) Compile time error
Correct op: D


Explanations
1) It would have been 5 5 5 if it were **m and not **p.

Q. Which of the following statements about stdout and stderr are true?
a) They both are the same
b) Run time errors are automatically displayed in stderr
c) Both are connected to the screen by default.
d) stdout is line buffered but stderr is unbuffered.
Correct Op: D

Explanation –
a) False. b) Not by default. c) Not by default. d) True.

Q: Given the below statements about C programming language:
1) main() function should always be the first function present in a C program file
2) all the elements of an union share their memory location
3) A void pointer can hold address of any type and can be typcasted to any type
4) A static variable hold random junk value if it is not initialised
Which of the above are correct statements?
A) 2,3
B) 1,2
C) 1,2,3
D) 1,2,3,4
Correct Op – A

Explanations
In a file you can write a function before main() – False
all the elements of an u