11. Which of the following function is correct that finds the length of a string?
Answer: int xstrlen (char *s) { int length=0; while (*s!='\0) { length++; s++; } return (length); }
Explanation:Here is no explanation for this answer
Workspace
Nagarro
12. Declare the following statement ?
"An Array of three pointers to chars"
Answer: char *ptr[3];
Explanation:Here is no explanation for this answer
Workspace
Nagarro
13. How will you print \n on the screen ?
Answer: printf(\\n);
Explanation:The statement printf("\\n"); prints '\n' on the screen.
Workspace
Nagarro
14. The use of the break statement in switch statement is
Answer: optional
Explanation:Here is no explanation for this answer
Workspace
Nagarro
15. What logic function is produced by adding an inverter to each input and the output of and OR gate?
Answer: NAND
Explanation:Here is no explanation for this answer
Workspace
Nagarro
16. Conversion of binary number 11110 to hexadecimal is
Answer: 1E
Explanation:Here is no explanation for this answer
Workspace
Nagarro
17. Let P be a quick sort program to sort numbers in ascending order using the first element as the pivot. Let t1 and t2 be the number of comparisons made by P for the input [1 2 3 4 5] and [4 1 5 3 2] respectively. Which one of the following holds?
Answer: t1 > t2
Explanation:When first element or last element is chosen as pivot, Quick Sort's worst case occurs for the sorted arrays.
In every step of quick sort, numbers are divided as per the following recurrence.
T(n) = T(n-1) + O(n)
Workspace
Nagarro TCS NQT
18. Identify the correct order in which the following actions take place in ad interaction between web browser and web server.
1) The web browser request a webpage using HTTP.
2) The web browser establish a TCP connection with the web server.
3) The web web server send the requested webpage using HTTP.
4) The web browser resolves the domain name using DNS.
Answer: 4,2,1,3
Explanation:Here is no explanation for this answer
Workspace
Nagarro
19. The Boolean expression AB + AB' + A'C + AC is unaffected by the value of Boolean variable:
Answer: B
Explanation:AB + AB' + A'C + AC = A(B + B') + (A' +A)C
= A(1) + (1) C = A + C = B
Workspace
Nagarro
20. Consider the C function given below. Assume the array listA contains (n>0) elements, sorted in ascending order.
int Process array (int * list A, int x, int n)
{
int i, j, k;
i =0;j=n-1;
do {
k = (i+j)/2;
if (x<=list A[k])
j=k-1;
if (list A[k] <=x)
i =k+1;
} while (i <=j);
if (list A[k] == x)
return (k);
else
return -1;
}
Answer: It is an implementation of binary search.
Explanation:Here is no explanation for this answer
Workspace
Nagarro Societe Generale TCS NQT