Join Regular Classroom : Visit ClassroomTech

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 union share their memory location – True.
A void pointer can hold address of any type and can be typcasted to any type –
True
Static value – False as value is 0
In C, if an object that has static storage duration is not initialized explicitly, then:
— if it has pointer type, it is initialized to a NULL pointer;
— if it has arithmetic type, it is initialized to (positive or unsigned) zero;
— if it is an aggregate, every member is initialized (recursively) according to these rules;
— if it is a union, the first named member is initialized (recursively) according to these rules.

Q If a function is defined as static, it means
A) The value returned by the function does not change
B) all the variable declared inside the function automatically will be assigned initial value of zero
C) It should be called only within the same source code / program file.
D) None of the other choices as it is wrong to add static prefix to a function
Correct Op: C
Access to static functions is restricted to the file where they are declared.
Therefore, when we want to restrict access to functions, we make them static.

Q Comment on the below while statement=
while (0 == 0) { }
A) It has syntax error as there are no statements within braces {}
B) It will run forever
C) It compares 0 with 0 and since they are equal it will exit the loop immediately
D) It has syntax error as the same number is being compared with itself
Correct Op: B

Explaination:
while( 0==0) {} is equivalent to while(1) {}

Previous Year TCS NQT Solve

Recent Posts
Pages