Sunteți pe pagina 1din 4

Technical Questions for TCS Interviews

(1) What is the output of the following program:


#include
void main()
{
printf("%d %d %d %d",65,065,0x65,0X65);
}
(2) What is the output of:
#include
void main( )
{
printf ( "nn nn nnn" ) ;
printf ( "nn /n/n nn/n" ) ;
}
(3) what will be the o/p of the program
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]);
}
(4) what will be the o/p of the program
void main()
{
int const * p=5;
printf("%d",++(*p));
}
(5) How do you call C functions from C++?
(6) Write a C program to print Date?

(7) Find the number of divisors of 1080 excluding the divisors which are perfect squares.
A. 28
B. 30
C. 29
D. 31
(8) Your challenge is to understand various ways of visualizing data and use that knowledge
to communicate to us. As the youth of the country, you represent the citizens of
tomorrow. We wish to understand your aspirations.
1. Visualize how you would like to spend the income you earn over the next 30 years.
What will your top 5 expenditures be?
2. Visualize how you would like your home (where you live) to look like 30 years from
now. Feel free to include any detail you wish (possessions, animals, people etc.)
3. Visualize how you would like the city/town/village that you would like to live in to
look like? Please give the name of your village/town (including the state and country),
and your vision for the place after 30 years.
4. Visualize your daily diet. (For eg. roti and daal) Visualize the nutritional value of the
food you described.
5. What food would you would like to see on your plate on a daily basis 30 years from
now. Visualize the food and the quantity of food. What would you like the next
generation of youth to eat.
(9) Minimum number of leaf nodes in a binary search tree of n nodes
(10)If the solutions of the equation x2 + px + q = 0 are the cubes of the solutions of the equation x2 +
mx + 2 = 0, then
p q = m3
p = m3q
p + q = m3
p = m3 + 6m
p = m3 6m
(11)It is a walk-in-interview setup having an interview room with
one chair and a waiting room with a number of chairs. The interviewer interviews
candidates in the interview room. When the interviewer finishes interviewing a candidate,
he dismisses the candidate and goes to the waiting room to see if there are other
candidates waiting. If there are, he brings one of them to his room and interviews him. If
there are no candidates waiting, he returns to his chair in the interview room and
continues reading his last unfinished magazine. If there are no unfinished magazines, he

starts reading a new magazine. After he finishes reading one full magazine, he goes to
sleep.
Each candidate, when he arrives, looks to see what the interviewer is doing. If the
interviewer is reading a magazine, the candidate waits for the interviewer to finish
reading the current page of the magazine. Then the candidate enters the interview room
and asks the interviewer to interview him. If the interviewer is sleeping, the candidate
wakes him up and then asks the interviewer to interview him. If the interviewer is
interviewing another candidate, the candidate goes to the waiting room. If there is a free
chair in the waiting room, the candidate sits in it and waits his turn. If there is no free
chair, then the candidate leaves.
Based on a naive analysis, the above description should ensure that the walk-ininterview
functions correctly, with the interviewer interviewing any candidate who arrives
until there are no more candidates, and then reading magazines and/or sleeping until the
next candidate arrives. In practice, there are a number of problems that can occur that
are illustrative of general scheduling problems. Please discuss those problems and
provide an algorithm to solve those problems.
Note: There are two doors between the interview room and the waiting room.
Tip: Read literature on the Dining Philosophers problem

(12)The challenge
You will need to phrase your question in multiple forms. In the first form, you can simply
state your question and solution. You will then need to transform question into a more
abstract form. This form can be thought of as a set of instructions that are required for a
computer to be able to solve a problem. You can also transform your question context in
a way that the solution remains the same. In another form, you can transform the
question formula, by retaining the question context. You can also invert the question so
that the formula is inverted. As you immerse yourself in the challenge, you will notice
that a number of interesting combinations of changes can result in a variety of interesting
questions.
In order to create such questions, you need to ask the following questions
1. How can variables be identified?
2. Are there different types of variables?
3. Are there limits to the values that a variable can take?
4. How are the variables related to each other and to the solution?
5. How can the context of the problem be changed? Can the same solution be
obtained by changing the context of the problem?
6. How can you play with the solution formula?
7. Can the problem be made more interesting and educational by adding relevant
textual content from leading international journals or magazines?
Please read the following steps and the example enclosed by which you will be able to
convert a question into an abstract form
1. A portion of a question is said to be generalized when that portion can be
replaced by a variable which can take a set of well defined values. Identify such

variables in the question statement and replace them with variable names such
as variable1, variable2 etc.
E.g. Co side the uestio A train travels at 50 Km/hr. Calculate the time it
takes to t avel 500 K . The u de li ed po tio a e epla ed y
another number(s). Hence that portion of the question is said to be generalized.
Note: In this example, we have chosen only one variable which is the speed of
the train. You may be able to identify many such variables in a question.

S-ar putea să vă placă și