TCS Previous Year Question 2017 Technical Question Part 1 | Placement Preparation | Tech With Code

 TCS Previous Year Question 2017


TECHNICAL 


Certain questions are self-explanatory. Thus detailed solutions are provided only wherever required.


1. What the below statement will print if a=5? printf("%d %d",a, !a++);

a. 5 0 b. 6 0 c. 5 1 d. 6 1


Answer: B


Explanation

 Values in the function get passed from right to left. First !a++ get processed which pass zero as argument and make a equal to 6


2. What is the output?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_c8067ad1937f728f247651288b3eb986afaa1054910592.png

a. 1 b. False c. Compiler Error d. No output


Answer: B


Explanation: 

In this program, we are comparing the addresses contained by ptr & ptr1 not the value at those addresses and pointers ptr and ptr1 have the addresses of different variables so above condition is false


3. How many times main() will get called? 

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_c8067ad1937f728f247651288b3eb986afaa291980653.png

a. Error b. Infinite times

c. No output d. None of these


Answer: B


Explanation: 

 There is no condition in the main() to stop the recursive calling of the  main()  hence it will be called infinite no of times.


4. Comment on the following?

const int *ptr;

a. You cannot change the value pointed by ptr

b. You can change the value of the pointer

c. None of these

d. You can change the pointer as well as the value pointed by it


Answer: A


Explanation: 

 Value of the pointer cannot be changed when const keyword is used


5. What is the output of the following program?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_c8067ad1937f728f247651288b3eb986afaa935712514.png

a. NULL b. Error c. 0 d. 1


Answer: D


Explanation: 

 ASCII codes are compared. ’A’ is 65 while ’a’ is 97


6. What is the output of the following program?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_c8067ad1937f728f247651288b3eb986afaa1001158108.png

a. 1 2 3 4 10 b. 1 2 3 4 14

c. 1 2 3 13 d. 1 2 3 14


Answer: B


Explanation: 

1,2,3,4 are printed. When a value is greater than 4, if condition becomes true and break is executed. (4+10)14 is printed


7. Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0)?

a.int *ptr = &a; b. int *ptr = &a - &a;

c.int *ptr = a -a; d. None of these


Answer: A


Explanation: 

 In *ptr = &a, the address of a is stored in pointer. In other cases, it is 0


8. What is the output of the following program?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_c8067ad1937f728f247651288b3eb986afaa651041792.png

a. 3 b.13 c. 123 d. 12


Answer: B


Explanation: 

go to statement jumps program execution to the label XYZ and skips 2.


9. The statement that transfers control to the beginning of the loop is called _______.

a. Break statement b. Exit statement

c. Goto statement d. continue statement


Answer: D


Explanation: 

 Continue statement continues with the next iteration of the loop


10. What is the output of following program?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_c8067ad1937f728f247651288b3eb986afaa343996500.png

a. 6 6.500000 b. 6 6.5

c. 6 6.000000 d. None of these


Answer: C


Explanation: 

The solution of 13/2 is obtained as an integer and decimal values are dropped before assigning to f


 TCS Previous Year Question 2017 



TECHNICAL


Certain questions are self-explanatory. Thus detailed solutions are provided only wherever required.


1. What is the purpose of ftell?

a. To get the current file name

b. To get the current file status

c. To get the current file attributes

d. To get the current file position


Answer: D


Explanation: 

 ftell() is used to find out the position of file pointer in the file with respect to starting of the file.


2. What will be the output of the below code?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_f57ed4ba4e656a577c62fe24cb84aff82064093454.png

a. NO output b. NO

c. Successfully complied but no output d. ERROR


Answer: C


Explanation: 

 No error and if condition fails so there is no output


3. What is the output of the below-mentioned programme?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_8e008b636a965586210ef5c60244f5f6620921816.png

a. sizeof(i) = 2 b. sizeof(i) = 1

c. compile Error d. None of these


Answer: B


Explanation: 

  int size is 2bytes or 4 bytes. Char size is 1 byte. Int is defined as Char. Sizeof(i) = 1


4. For passing command line argument the main function should be like

a. int main(int argc, char *argv[])

b. int main(int argc)

c. int main(char *argv[])

d. int main(char *argv[], int argc)


Answer: A

Explanation: 

 Command Line Arguments Syntax


5. Where the local variables are stored?

a. Disk b. Stack c. Heap d. OS


Answer: B


Explanation: 

 Local Variable is stored in stack


6. Which of the below functions is NOT declared in string.h?

a. strptr () b. strcpy ()

c. strlen() d. strupr()


Answer: A


Explanation: 

 strptr() is not declared


7. What is the output of the below-mentioned programme?

http://d1gyfhtoityo9s.cloudfront.net/modules/emanager/ques/img/tmp_9ec59732916c9c321aeca0853e14b7101636766539.png

a. 16 b. Compilation Error

c. 64 d. 4


Answer: C


Explanation: 

 It executes based on the operator precedence. 64 / 4 * 4.  16*4 = 64


8. What is the format of conditional operator?

a. Condition? true value: false value

b. Condition! true value: false value

c. Condition? false value: true value

d. Condition? true value: :false value


Answer: A


Explanation: 

                  Syntax


9. What is recursion?

a. Looping

b. A function calls another function repeatedly

c. A function calls repeatedly

d. A function calls itself repeatedly


Answer: D


Explanation: 

 In recursion, the function calls itself repeatedly


10. A memory leak happens when?

a. A program allocates memory in heap but forget to delete it.

b. A program allocates memory in stack.

c. When an unsigned pointer is freed using free function.

d. When realloc() is called on a pointer that is not allocated


Answer: A


Explanation: 

 A memory leak occurs when programmers create a memory in heap and forget to delete it.



No comments:

Do not add any link in the comments.
For backlink, contact us.

Powered by Blogger.