NCR Placement Paper : Technical - C & C++
NCR Placement Paper and Sample Paper
The pattern for the company NCR Teradata in HYD.
The exam was of 1:45 and consisted of C,C++,DataStructures, total 4(5 Marks)... but I couldn,t get thru....
Note that the code or the values may not be correct.... Just get the concept.
Predict the o/p... each 1 mark
1.
static int i;
{
i=10;
...
}
printf("%d",i);
Ans: 10
2.
#define func1(a) #a
#define func2(a,b,c) a##b##c
printf("%s",func1(func2(a,b,c)))
Ans: func2(a,b,c)
3.
const int* ptr;
int* ptr1;
int a=10;
const int p=20;
ptr=a;
ptr1=p;
4.
class a
virtual disp()
{ printf("In a");}
class b:public a
disp()
{ printf("In b");}
class c:public a
disp()
{ printf("In c");}
main()
{
a obj;
b objb;
c objc;
a=objb;
a.disp();
a=objc;
a.disp();
Ans: "In a" "In a"
5.
a="str";
char *b="new str";
char *temp;
malloc(sizeof(temp)+1,....
strcpy(a,temp);
malloc(sizeof(b)+1,....
strcpy(temp,b);
6.
int m,i=1,j=0,k=-1;
m=k++||j++&&i++;
printf("%d...",m,i,j,k);
7.
class x
{
double b;
double *l;
float &c;
}
main()
{
double g=10.34;
double *f=1.3;
float k=9;
x o;
o.b=g;
o.l=f;
o.c=k;
}
Ans: Compiler Error
Write C/C++ code for following:
For all the probs, u will have decide on wht DS to use.... and u,r program must be efficient...explain in detail... (5 Marks)
1. Find the Kth smallest element in a Binary Tree. (5 Marks)
2. Each worker does a job and is given a rating +ve,-ve or Zero.
Find the MaxSubSequenceSum for given no. of workers.
Ex: Workers=6; Ratings={1,0,-1,4,5,-3}
MaxSubSequenceSum=4+5=9 (5 Marks)
3. 1 to N ppl sitting in a circle. Each one passes a hot potato to the next person. After M passes the person holding the potato is eliminated. The last person remaining is winner. Find winner for given N,M.
Ex: N=5, M=2, Winner=4 (5 Marks)
4. Reverse a given Linked List. (5 Marks)
5. There is a file called KnowledgeBase.txt which contains some words. Given a sub-string u have to find all the words which match the word in the file.
Ex: file contains a, ant, and, dog, pen.
If I give "an" I should get o/p as "ant, and" (10 Marks)
6. Company employee have id,level,no. of sub-ordinates under him...
If a emp leaves then his sub-ordinates are assigned to any of the emp,s seniors...
Write four functions: