Tcs Technical MCQ
Tcs Technical MCQ
Tcs Technical MCQ
Notebook: <Inbox>
Created: 30-07-2019 23:40 Updated: 07-08-2019 00:35
Author: [email protected]
Tags: Selfless(freshers job), TCS 2019
#include
int main()
return 0;
1. 54321061
2. 543210
3. 5432101
4. 5432106
q2.
main()
1.FACE4
2. Error
3. Garbage value
4. FACE
quetion 3.#include
int main()
int i,j;
for(i=0;i<5;i++)
i=j=i;
j=0;
printf("%d",j);
ANS=0
main()
printf(“hai”);
else
printf(“hello”);
1. Error
2. hai
3. hello
4. No output
quetion 4.
int a=10,x;
x= a-- + ++a;
printf(“%d”,x);
1. 19
2. 20
3. 22
4. 23
quetion 5.
#include
int main()
return 0;
1. 12344
2. 12341
3. 11234
4. 41234
quetion5.
main()
int a=b=c=d=10;
1. Error
2. 10,10,10,10
3. GV,GV,GV,10
4. GV,GV,GV,GV
quetion6.
main()
int x,a=10;
x=a==10?printf("hait"):printf("hellon");
printf("%d",x);
1.hait4
2. Error
3. hello 3
4. hait hello
quetion 7.
1) main() function should always be the first function present in a C program file
3) A void pointer can hold address of any type and can be typcasted to any type
When a pointer variable is declared using keyword void – it becomes a general purpose pointer variable.
Address of any variable of any data type (char, int, float etc.)can be assigned to a void pointer variable.
2. Introduction to pointers in C, We use the indirection operator * to serve the purpose. But in the case of a void
pointer we need to typecast the pointer variable to dereference it. This is because a void pointer has no data type
associated with it. There is no way the compiler can know (or guess?) what type of data is pointed to by the void
pointer. So to take the data pointed to by a void pointer we typecast it with the correct type of the data holded
inside the void pointers location.
(int*)ptr - is used for type casting. Where as *((int*)ptr) dereferences the typecasted void
pointer variable.
quetion8.
main()
int i=10;
printf(“%d,%d”,++i,++i);
1. 11,12
2. 12,11
3. 10,11
4. 11,10
quetion 9.
1. conio.h
2. stdio.h
3. math.h
4. Dos.h
quetion 20.
main()
int x,a=10;
1. 51
2. 51.5
3. 31
4. None of these
quetion 11.
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
quetion 12.
B : int fun();
4.None of these
quetion 13.
main()
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("n%c%c%c%c",s[i ],*(s+i),*(i+s),i[s]);
}
output::nmmmmnaaaannnnn
quetion 14.
main()
printf(“n ks”);
printf(“b mi a”);
printf(“r ha n”);
1. ksmiha
2. mis
3. hai
4. hamiks
quetion 15.
main()
int a=2;
switch(a)
case 1: printf(“one”);
case 2: printf(“Two”);
case 3: printf(“Three”);
default:printf(“Invalid option”);
}
1. onetwothree
2. Invalid option
3. one two
4. None of these
quetion 16.
If a function’s return type is not explicitly defined then it’s default to ______ (In C).
A) int
B) float
C) void
D) Error
Answer:a
quetion 16. How many times the below loop will be executed?
#include
int main()
{
int i;
for(i=0;i<5;i++) printf(“Hello\n”); } A) 5 B) 1 C) 0 D) 3 Answer:a
quetion20. while declaring parameters for main, the second parameter argv should be declared as
a) char argv[]
b) char argv
c) char ** argv[]
d) char * argv[]
a) calloc
b) malloc
c) Both calloc & malloc
d) free
#include <stdio.h>
void main()
{
int x = 97;
int y = sizeof(x++);
printf(“x is %d”, x);
}
a) x is 97
b) x is 98
c) x is 99
quetion29.Eesha was in a wonderland where she saw a treasure trove of seven items of various items (in
lakhs) and weights (in kgs) as per the table given below.
1 12 4
2 10 6
3 8 5
4 11 7
5 14 3
6 5 10
7 5 12
She wanted to bring back maximum value of items but she was not able to carry more than 10 kgs. Using
dynamic programing, what is the maximum value of of the items that she could carry back with her.
Answer: 26
Question 30
In c language, if a function return type is not explicitly defined then it defaults to what data type?
Answer: Int
Question 31
Question 32
Advanced The figure depicts a search space in which the nodes are labelled with names like A,B,A1,B1.
Node S is the start node. The goal are drawn as square boxes and the other noted in circle Enter answer
as a sequence of node separated by a comma, please DO NOT enter any blanks anywhare in the response
For example, If the answer (order of nodes) is a followed by c, followed by A1, followed by D, the answer
should be A,C,A1,D
Starting with the node start node,list the order in which the depth first search algorithm explore the graph
till termination, searching from right to left until it reaches one of the goal nodes.
Answer: S,C,J,T,I1
Question 33
a. Push ,pop
b. Push,pop,remove
c. Push,pop, add,remove
d. Push,pop,add,remove,substitute
Answer: push,pop
Question 34
a. Get back the memory that was released earlier using dree() funcion
Question 35
Advanced Consider a hash function that distributes keys uniformly. The hash table size is 20. After
hashing of how many keys will the probability that any new key hashed collides with an existing one
exceed 0.5.
a. 10
b. 7
c. 6
d. 5
Answer: 10
Question 37
1. Signed int
2. Big int
3. Short int
4. Long int
Question 38
Eesha wants to implement an image viewer application to view images in a given folder. The application
will be able to display an image and will also know what its next and previous images are at any given
point of time so that the user can so that the user can view next/previous image by pressing right/left keys
on the keyboard. Which data structure is appropriate for Esha to use?
1. Tree
2. Queue
3. Linked list
4. Stack
Question 39
The pseudo code below sorts an array using bubble sort. Here A is the array and the” n” is the number of
element in it. Function swap exchanges the value of 2 given value.
1. Function bubbleSort(A,B)
2. {
3. For i =0 to n-2 step 1
4. For j = 0 to n-1-2 step 1
5. if( A (j) > A(j+1))
6. Swap(A(j),A(j+1))
7. }
This function is called with A and 7 as parameter where the array a initially contains the element 64, 34,
25,12, 22, 11, 9
1. 34 25 12 22 11 9 64
2. 25 12 22 11 9 34 64
3. 11 9 12 22 25 34 64
4. 12 11 9 22 25 34 64
Answer:25 12 22 11 9 34 64
Question 40
Advanced Consider a hash function that distributes keys uniformly. The hash table size is 20. After
hashing of how many keys will the probability that any new key hashed collides with an existing one
exceed 0.5.
1. 10
2. 7
3. 6
4. 5
Question 41
#define is used to
a. Define a variable
b. Define a macro
c. Define a function
d. Define a constant
Question 42
Question 43
a. Extern
b. Dynamic
c. Register
d. Auto
Question 44
Eesha is developing a word processing software in which she wants to provide undo feature.the software
will maintain all the sequential changes and at any point of time pressing control z will undo the latest
change,what data structure should Eesha use for this?
a. Stack
b. Queue
c. Linked list
d. Array
Question 45
#include<stdio.h>
Main(int argc,char**argv)
printf(“%s\n”,argv[–argc]);
Return 1;
The above program was run with the following command line parameters
a. Nisha
d. Eesha
Question 46
Considering a hash table with 100 slots. Collisions are resolved using chaining. Assuming simple uniform
hashing, what is the probability that the first 3 slots are unfilled after the first 3 insertions? (NOTE:100 ^ 3
means 100 raised to the power 3)
c. (97 * 97 * 97 ) / 100 ^ 3
Question 47
Advanced Consider the following graph starting at node A. In what order will the nodes be visited using a
breadth first search?
NOTE 1 : Is there is ever a decision between multiple neighbour nodes in the algorithm, assume we always
choose the letter closest to the beginning of the first alphabet
NOTE 2: Enter the answer as a sequence of nodes separated by a comma. Please do NOT enter any blanks
anywhere in the response. For example, is the answer (order of nodes) is A followed by C, followed by X,
followed by D. the answer should be A,C,X,D.
Answer: A,B,D,E,G,C,H,F
Question 48
This function is called with A and 7 as parameters where the array A initially contains the elements
34,14,65 be the value of the elements in A after 3 iterations of the outer loop?
a. 14 12 22 5 34 65 71
b. 14 34 22 12 65 5 71
c. 14 22 12 34 5 65 71
Question 50
Eesha is developing an IP telephony software in which the audio is encoded and transmitted by the sender
as network packets through a communication channel. At the other end these packets are assembled and
processed further.eesha recognizes that there maybe a very large number of packets this number is
unknown nd which will be processed while more packets are being received .assume that the packets
arrive in right order .what data structure should eesha use?
Array
List
Queue
Stack
Question 51
A structure in C language is
System defined data type that holds predefined collection of data types
User defined data type holding similar or dissimilar data types
Another name for union data type
A collection of similar user defined data type
Question 52
Question 53
For(i=7;i!=0;i–)
Print(“%d”,i);
Ch=get char();
What will be the output?
Compilation error
infinite loop
Number display from 7 to 1 in descending order.
Number display from 7 to 0 in descending order
Question 54
stack
queue
linked list
tree
Question 55
int
long int
float
double
Question 56
main(int argc,char*argv[])
An array of character pointers the first array item pointing to the program name and remaining
pointing to the command line parameters
An array of character pointer each pointing to the command line parameters
A pointer to character that points to command line parameters
A pointer to pointer that points to the memory location where the program has been loaded to
the memory
Question 57
1.Infinite loop
3.None of the other choices as there is a compilation error Numbers 7 to 1 in descending order.
Question 58
Eesha works for ISRO where she is involved in a mission to intercept a comet that is likely to collide with
in each with in 1 month.she is developing a c program to calculate the trajectory of the missile to be
launched to intercept and destroying the approaching comet.in order to achieve highest accuracy of the
missile trajectory what data type should she use for the variables in her equation??
1. Long int
2. Double
3. Float
4. Int
Question 59
a program reads in 500 integers in the range [0…100]representing the scores of 500 students.it then prints
the frequency of each score above 50.what would be the best way for the program to store the
frequencies?
1. An array of 101 numbers
2. An array of 50 numbers
3. An array of 500 numbers
4. A dynamically allocated array of 550 numbers
Question 60
The number of nodes on the last level is equal to the sum of the number of nodes on all other levels
Question 61
Int main ()
Int n;
If (n.=1)
Else
Return 1;
Ans: recursion
Question 62
Not a core of os
1. multi tasking
2. memory management
3. virus protection
4. file management
Question 63
Question 64
Esha writes a prgm for factorial but she forgot to write the function fact what is the error displayed
A)file not found
B)syntax errors
Question 65
Eesha wants to incorporate a history feature .When she presses “go back” then it will be able to be vist the previous page.what
data type is used ?
1. Tree
2. Queue
3. Stack
4. Array.