User:Kapilkn
From Wikipedia, the free encyclopedia
== Placement Papers for Campus/off Campus(C/C++) ==
== By Kapil Engineer (Nagwanshi) == More Good Luck to all of you (© Kapil K Nagwanshi ; NIT-RR) Kapilkn@gmail.com --59.95.128.217 00:58, 16 May 2007 (UTC)
Give the output of the programs in each case unless mentioned otherwise
1. void main() {
int d=5;
printf("%f",d);
}Ans: Undefined
2. void main() {
int i;
for(i=1;i<4,i++)
switch(i)
case 1: printf("%d",i);break;
{
case 2:printf("%d",i);break;
case 3:printf("%d",i);break;
}
switch(i) case 4:printf("%d",i);
}Ans: 1,2,3,4
3. void main() {
char *s="\12345s\n";
printf("%d",sizeof(s));
}Ans: 6
4. void main() {
unsigned i=1; /* unsigned char k= -1 => k=255; */ signed j=-1; /* char k= -1 => k=65535 */
/* unsigned or signed int k= -1 =>k=65535 */ if(i<j)
printf("less");
else if(i>j)
printf("greater");
else if(i==j)
printf("equal");
}Ans: less
5. void main() {
float j;
j=1000*1000;
printf("%f",j);
}
1. 1000000 2. Overflow 3. Error 4. None Ans: 4
1. How do you declare an array of N pointers to functions returning pointers to functions returning pointers to characters? Ans: The first part of this question can be answered in at least three ways:
2. Build the declaration up incrementally, using typedefs:
typedef char *pc; /* pointer to char */
typedef pc fpc(); /* function returning pointer to char */
typedef fpc *pfpc; /* pointer to above */
typedef pfpc fpfpc(); /* function returning... */
typedef fpfpc *pfpfpc; /* pointer to... */
pfpfpc a[N]; /* array of... */
3. Use the cdecl program, which turns English into C and vice versa:
cdecl> declare a as array of pointer to function returning pointer to function returning pointer to char char *(*(*a[])())()
cdecl can also explain complicated declarations, help with casts, and indicate which set of parentheses the arguments go in (for complicated function definitions, like the one above). Any good book on C should explain how to read these complicated C declarations "inside out" to understand them ("declaration mimics use"). The pointer-to-function declarations in the examples above have not included parameter type information. When the parameters have complicated types, declarations can *really* get messy. (Modern versions of cdecl can help here, too.)
4. A structure pointer is defined of the type time . With 3 fields min,sec hours having pointers to intergers.
Write the way to initialize the 2nd element to 10.
5. In the above question an array of pointers is declared. Write the statement to initialize the 3rd element of the 2 element to 10
6. int f() void main() {
f(1); f(1,2); f(1,2,3);
} f(int i,int j,int k) {
printf("%d %d %d",i,j,k);
}What are the number of syntax errors in the above? Ans: None.
7. void main() {
int i=7;
printf("%d",i++*i++);
}Ans: 56
8. #define one 0
- ifdef one
printf("one is defined ");
- ifndef one
printf("one is not defined "); Ans: "one is defined"
9. void main() {
intcount=10,*temp,sum=0;
temp=&count;
*temp=20;
temp=∑
*temp=count;
printf("%d %d %d ",count,*temp,sum);
} Ans: 20 20 20
10. There was question in c working only on unix machine with pattern matching.
11. what is alloca() Ans : It allocates and frees memory after use/after getting out of scope
12. main() {
static i=3;
printf("%d",i--);
return i>0 ? main():0;
} Ans: 321
13. char *foo() {
char result[100]); strcpy(result,"anything is good"); return(result);
} void main() {
char *j;
j=foo()
printf("%s",j);
} Ans: anything is good.
14. void main() {
char *s[]={ "dharma","hewlett-packard","siemens","ibm"};
char **p;
p=s;
printf("%s",++*p);
printf("%s",*p++);
printf("%s",++*p);
}
15. Ans: "harma" (p->add(dharma) && (*p)->harma) "harma" (after printing, p->add(hewlett-packard) &&(*p)->harma) "ewlett-packard"
Sample Test Paper :Alter Engineering
1. int b=10;
int *p=&b;
- p++;
printf("%d",*p);
what is the output?
2. What is the difference between malloc, calloc and realloc?
3. What does malloc return in C and C++?
4. main() { char *a="hello"; char *b="bye"; char *c="hai"; int x=10,y=100; c=(x<y>)?a:b; printf("%s",c); } whats the output?
5. void main() {
int a,b;
a=sumdig(123);
b=sumdig(123);
printf("%d %d",a,b);
} int sumdig(int n) {
static int sum; int d; if(n!=0)
{ d=n%10; n=(n-d)/10;
sum=sum+d; sumdig(n);
} else return s; } what is the output?
6. Declare a pointer to a function that takes a char pointer as argument and returns a void pointer.
7. How do we open a binary file in Read/Write mode in C?
C++
8. class A { public: A() { } ~A(); }; class derived:public A { derived(); }; what is wrong with this type of declaration?
9. what do you mean by exception handling?
10. What are "pure virtual" functions?
11. What is the difference between member functions and static member functions?
12. What is the4 difference between delete[] and delete?
13. Question on Copy constructor.
14. What are namespaces?
15. One question on namespace.
16. What are pass by valu and pass by reference? what is the disadvantage of pass by value? I didnt get this. if you have the answer plz tell me.
17. How to invoke a C function using a C++ program?
18. char *str; char *str1="Hello World"; sscanf(str1,"%s",str); what is the output?
19. Difference between function overloading and function overriding.
20. There is a base class sub, with a member function fnsub(). There are two classes super1 and super2 which are subclasses of the base class sub. if and pointer object is created of the class sub which points to any of the two classes super1 and super2, if fnsub() is called which one will be inoked?
i2 Technologies
Q1.Convert 0.9375 to binary
a) 0.0111 b) 0.1011 c) 0.1111 d) none
Ans. (c)
Q2.( 1a00 * 10b )/ 1010 = 100
a) a=0, b=0 b)a=0, b=1 c) none
Ans. (b)
Q3. In 32 bit memory machine 24 bits for mantissa and 8 bits for exponent. To increase the range of floating point.
a) more than 32 bit is to be there. b) increase 1 bit for mantissa and decrease 1 bit for exponent c) increase 1 bit for exponent and decrease one bit for mantissa
Q4.In C, "X ? Y : Z " is equal to
a) if (X==0) Y ;else Z b) if (X!=0) Y ;else Z c) if (X==0) Y ; Z
Ans. (b)
Q5. From the following program
foo()
int foo(int a, int b)
{
if (a&b) return 1;
return 0;
}
a) if either a or b are zero returns always 0 b) if both a & b are non zero returns always 1 c) if both a and b are negative returns 0
Q6. The following function gives some error. What changes have to be made
void ( int a,int b)
{
int t; t=a; a=b; b=t;
}
a) define void as int and write return t
b) change everywhere a to *a and b to *b
Q7. Which of the following is incorrect
a) if a and b are defined as int arrays then (a==b) can never be true
b) parameters are passed to functions only by values
c) defining functions in nested loops
Q8. include<stdio.h>
void swap(int*,int*);
main()
{
int arr[8]={36,8,97,0,161,164,3,9}
for (int i=0; i<7; i++)
{
for (int j=i+1; j<8;j++)
if(arr[i]<arr[j]) swap(&arr[i],&arr[j]);
}
}
void swap(int*x,int*y)
{
int temp; static int cnt=0;
temp= *x;
*x=*y;
*y=temp;
cnt++;
}
What is cnt equal to
a) 7 b) 15 c) 1 d) none of these
Q9. int main()
{
FILE *fp;
fp=fopen("test.dat","w");
fprintf(fp,'hello\n");
fclose(fp);
fp=fopen ("test.dat","w");
fprintf (fp, "world");
fclose(fp);
return 0;
}
If text.dat file is already present after compiling and execution how many bytes does the file occupy ?
a) 0 bytes b) 5 bytes c) 11 bytes d) data is insufficient
Q10. f1(int*x,intflag)
int *y;
*y=*x+3;
switch(flag)
{
case 0:
*x=*y+1;
break;
case 1:
*x=*y;
break;
case 2:
*x=*y-1;
break;
}
return(*y)
main()
{
*x=5;
i=f1(x,0); j=f1(x,1);
printf("%d %d %d ",i,j,*x);
}
What is the output?
a) 8 8 8 b) 5 8 8 c) 8 5 8 d) none of these
Mistral Solutions
C Section
1. What does the following program print?
- include <stio.h>
int sum,count; void main(void) {< BR> for(count=5;sum+=--count;) printf("%d",sum); } a. The pgm goes to an infinite loop b. Prints 4791010974 c. Prints 4791001974 d. Prints 5802112085 e. Not sure
2. What is the output of the following program?
- include <stdio.h>
void main(void) { int i;< BR> for(i=2;i<=7;i++) printf("%5d",fno()); } fno() { staticintf1=1,f2=1,f3; return(f3=f1+f2,f1=f2,f2=f3); } a. produce syntax errors b. 2 3 5 8 13 21 will be displayed c. 2 2 2 2 2 2 will be displayed d. none of the above e. Not sure
3. What is the output of the following program?
- include <stdio.h>
void main (void) { int x = 0x1234; int y = 0x5678; x = x & 0x5678; y = y | 0x1234; x = x^y; printf("%x\t",x); x = x | 0x5678; y = y & 0x1234; y = y^x; printf("%x\t",y); } a. bbb3 bbb7 b. bbb7 bbb3 c. 444c 4448 d. 4448 444c e. Not sure
4. What does the following program print?
- include <stdio.h>
void main (void) { int x; x = 0; if (x=0) printf ("Value of x is 0"); else printf ("Value of x is not 0"); } a. print value of x is 0 b. print value of x is not 0 c. does not print anything on the screen d. there is a syntax error in the if statement e. Not sure
5. What is the output of the following program?
- include <stdio.h>
- include <string.h>
int foo(char *); void main (void) { char arr[100] = {"Welcome to Mistral"}; foo (arr); } foo (char *x) { printf ("%d\t",strlen (x)); printf ("%d\t",sizeof(x)); return0; } a. 100 100 b. 18 100 c. 18 18 d. 18 2 e. Not sure
6. What is the output of the following program?
- include <stdio.h>
display() { printf ("\n Hello World"); return 0; } void main (void) { int (* func_ptr) (); func_ptr = display; printf ("\n %u",func_ptr); (* func_ptr) (); } a. it prints the address of the function display and prints Hello World on the screen b. it prints Hello World two times on the screen c. it prints only the address of the fuction display on the screen d. there is an error in the program e. Not sure
7. What is the output of the following program?
- include <stdio.h>
void main (void) { int i = 0; char ch = 'A'; do putchar (ch); while(i++ < 5 || ++ch <= 'F'); } a. ABCDEF will be displayed b. AAAAAABCDEF will displayed c. character 'A' will be displayed infinitely d. none e. Not sure
8. What is the output of the following program?
- include <stdio.h>
- define sum (a,b,c) a+b+c
- define avg (a,b,c) sum(a,b,c)/3
- define geq (a,b,c) avg(a,b,c) >= 60
- define lee (a,b,c) avg(a,b,c) <= 60
- define des (a,b,c,d) (d==1?geq(a,b,c):lee(a,b,c))
void main (void) { int num = 70; char ch = '0'; float f = 2.0; if des(num,ch,f,0) puts ("lee.."); else puts("geq..."); } a. syntax error b. geq... will be displayed c. lee.. will be displayed d. none e. Not sure
9. Which of the following statement is correct? a. sizeof('*') is equal to sizeof(int) b. sizeof('*') is equal to sizeof(char) c. sizeof('*') is equal to sizeof(double) d. none e. Not sure
10. What does the following program print?
- include <stdio.h>
char *rev(int val); void main(void) { extern char dec[]; printf ("%c", *rev); } char *rev (int val) { char dec[]="abcde"; return dec; } a. prints abcde b. prints the address of the array dec c. prints garbage, address of the local variable should not returned d. print a e. Not sure
11. What does the following program print? void main(void) { int i; static int k; if(k=='0') printf("one"); else if(k== 48) printf("two"); else printf("three"); } a. prints one b. prints two c. prints three d. prints one three e. Not sure
12. What does the following program print?
- include<stdio.h>
void main(void) { enum sub { chemistry, maths, physics }; struct result { char name[30]; enum sub sc; }; struct result my_res; strcpy (my_res.name,"Patrick"); my_res.sc=physics; printf("name: %s\n",my_res.name); printf("pass in subject: %d\n",my_res.sc); } a. name: Patrick b. name: Patrick c. name: Patrick pass in subject: 2 pass in subject:3 pass in subject:0 d. gives compilation errors e. Not sure
13. What does printf("%s",_FILE_); and printf("%d",_LINE_); do? a. the first printf prints the name of the file and the second printf prints the line no: of the second printf in the file b. _FILE_ and _LINE_ are not valid parameters to printf function c. linker errors will be generated d. compiler errors will be generated e. Not sure
14. What is the output of the following program?
- include <stdio.h>
void swap (int x, int y, int t) { t = x; x = y; y = t; printf ("x inside swap: %d\t y inside swap : %d\n",x,y); } void main(void) { int x; int y; int t; x = 99; y = 100; swap (x,y,t); printf ("x inside main:%d\t y inside main: %d",x,y); } a. x inside swap : 100 y inside swap : 99 x inside main : 100 y inside main : 99 b. x inside swap : 100 y inside swap : 99 x inside main : 99 y inside main : 100 c. x inside swap : 99 y inside swap : 100 x inside main : 99 y inside main : 100 d. x inside swap : 99 y inside swap : 100 x inside main : 100 y inside main : 99 e. Not sure
15. Consider the following statements: i) " while loop " is top tested loop ii) " for loop " is bottom tested loop iii) " do - while loop" is top tested loop iv) " while loop" and "do - while loop " are top tested loops. Which among the above statements are false? a. i only b. i & ii c. iii & i d. ii, iii & iv e. Not sure
16. Consider the following piece of code: char *p = "MISTRAL"; printf ("%c\t", *(++p)); p -=1; printf ("%c\t", *(p++)); Now, what does the two printf's display? a. M M b. M I c. I M d. M S e. Not sure
17. What does the following program print?
- include <stdio.h>
struct my_struct { int p:1; int q:1; int r:6; int s:2; }; struct my_struct bigstruct; struct my_struct1 { char m:1; }; struct my_struct1 small struct; void main (void) { printf ("%d %d\n",sizeof (bigstruct),sizeof (smallstruct)); } a. 10 1 b. 2 2 c. 2 1 d. 1 1 e. Not sure
18. Consider the following piece of code: FILE *fp; fp = fopen("myfile.dat","r"); Now fp points to a. the first character in the file. b. a structure which contains a char pointer which points to the first character in the file. c. the name of the file. d. none of the above. e. Not sure.
19. What does the following program print?
- include <stdio.h>
- define SQR (x) (x*x)
void main(void) { int a,b=3; a = SQR (b+2); } a. 25 b. 11 c. 17 d. 21 e. Not sure.
20. What does the declaration do? int (*mist) (void *, void *); a. declares mist as a function that takes two void * arguments and returns a pointer to an int. b. declares mist as a pointer to a function that has two void * arguments and returns an int. c. declares mist as a function that takes two void * arguments and returns an int. d. there is a syntax error in the declaration. e. Not sure.
21. What does the following program print?
- include <stdio.h>
void main (void) { int mat [5][5],i,j; int *p; p = & mat [0][0]; for (i=0;i<5;i++) for (j=0;j<5;j++) mat[i][j] = i+j; printf ("%d\t", sizeof(mat)); < BR> i=4;j=5; printf( "%d", *(p+i+j)); } a. 25 9 b. 25 5 c. 50 9 d. 50 5 e. Not sure
22. What is the output of the following program?
- include <stdio.h>
void main (void) { short x = 0x3333; short y = 0x4321; long z = x; z = z << 16; z = z | y; printf("%1x\t",z); z = y; z = z >> 16; z = z | x; printf("%1x\t",z); z = x; y = x && y; z = y; printf("%1x\t",z); } a. 43213333 3333 1 b. 33334321 4321 4321 c. 33334321 3333 1 d. 43213333 4321 4321 e. Not sure
23. What is the output of the following program?
- include <stdio.h>
void main (void) { char *p = "Bangalore";
- if 0
printf ("%s", p);
- endif
} a. syntax error #if cannot be used inside main function b. prints Bangalore on the screen c. does not print anything on the screen d. program gives an error "undefined symbol if" e. Not sure
24. If x is declared as an integer, y is declared as float, consider the following expression: y = *(float *)&x; Which one of the following statments is true? a. the program containing the expression produces compilation errors; b. the program containing the expression produces runtime errors; c. the program containing the expression compiles and runs without any errors; d. none of the above e. Not sure
25. What is the return type of calloc function? a. int * b. void * c. no return type: return type is void d. int e. Not sure
part 1 of paper
first aptitude having five sections (50 questions and 45 minutes)
part 2 second c debugging (test ur c skills - yashwant kanitkar)(questions 20 time 30 min.)
paper 1
section one
15 questions (data sufficiency) a alone is sufficient b alone is sufficient a and b are both sufficient a and b both are insufficient
section two
five questions (reading comprehence ) very easy
section three
15 questions (logical reasoning) a pare is given and some hints are given u can fine out the ans
one hotel has two zones (east and west) not all east zone flats have ocean view but all weat zone flats have harbour view all ocean view flats has extra charge in harbour view flats above and on 3rd floor have extra charge west zone flats lower than 3rd floor some has kitchen so extra charge all other flats of east zone not having ocean view has kitchen so extra charges
section four
10 questions verbal reasoning four or five sentences are given related to single topic four options are given which are having order of three sentences(abe or bec) select correct order
sections five
five computational questions which were easy
- total 12 members half are in club a one third in b and one fourth in c how many are not in any club
ans 5(check)
these type of questions u can find in R. S. Agrawal or IMS package of CAT
in question it was written that all five sections carry their cutoffs so attempt all but in electrical one guy was selected who didnot attempt reading comprehension but attempted all 45 questions this paper also has negative marking of 50%
paper 2
1.what does p in const char *p stands for p can be changed like this
2.main() sturct date { char name[20]; int age ; float sal; }; sturct data d ={"rajesh"}; printf("%d%f",d.age,d.sal); } tell the output
3.main() int i=7; printf("%d"i++*i++); output
4.void main() { int d ; int i=10; d =sizeof(++i); printf("%d"); output
5.difference between extern int f(); int f();
6.choose correct (i)stack is automatically cleared (ii)heap is automatically cleared (iii)user has to clear stack and heap (iv)system takes care of ----------
7. What'll be the output: main() {char *a,*f(); a=f(); printf("%s",a); } char *f() {return("Hello World");
8.What'll be the output: main() {char*a,*f(); a=char*malloc(20*sizeof(char)); a=f(); printf("%s",a); } char *f() {char n[20]; strcpy(n,"Hello World"); return(n); } 9.What is the error : main() {int j=10; switch(j) { case 20: pritnf("Less than 20"); break; case 30: printf("Less than 30"); break; default: printf("hello"); }
10.which is valid : (i)char arr[10]; arr="hello"; (ii) char arr[]="hello";
11. main() { char *str; str=char*malloc(20*sizeof(char)); strcpy(str,"test"); strcat(str,'!'); printf("%s",str); }
12. How many times main is get called : main() { printf("Jumboree"); main(); } ans: till stack overflow.
13. Which statement is true about main : (i) Varible no. of Arguments can be passed main. (ii) Main can be called from main(); (iii) We can't pass arguments are passed in main (iv) main always returns an int
14. Output ? main() { int i,j; for(i=0,j=0;i<5,j<25;i++,j++); printf("%d %d",i,j); }
15.main() { int i; if(i=0) //it's assisnment not logical operator printf(" Hell "); else printf("Heaven"); like this no negative marking and more than one answers but paper I is cutoff paper i think c paper will not be checked
Interview
they will give u puzzles in first round which will be from site techinterview.org this site has 70 puzzles and their answers so go through them
second round has c coding of data structure circular quese,tree etc also questions from c and c++ like virtual functions far near huge memory concepts like heap,stack etc
then in third round hr questions like hobbies and interets make ur curriculam vite and bring it with ur file
they want people with good aptitude in interview rounds ur aptitude and approach matters so solve puzzles.
Ubinetics Test Pattern- July 2003
20 c objective Qs to be answered in 30 minutes All questions are related to basic c concepts like expression, arrays, loops ,structure , pointers around 3 or 4 qs on array with loops
Since paper is very easy cutoff is very high.
They will select 20% of the student for the interview after written test. Freshersworld.com
point to remember.
Each correct ans 1 marks Each wrong answer 1 -ve mark Sample Paper
Some of the questions will not have answers .Please forgive us.
1. Difference b/n scanf("%s",msg);and scanf("%[\^n]",msg); where msg is a char array. 2. What is ure of comma operator in for loop. 3. int shw(int *a){
*a = 10; /* return stmt is missing */
}
main(){
int p=3,q=4;
q = shw(&p);
printf("%d %d",p,q); }
4. which is true
a. all automatic variables are declared with in the function b. all variables are automatic c. all not declared variables are automatic d. none
5. What is recursion. Recursive prog to generate Fibonacci series . Is it a best method? 6. write 7*a interms of +,-,<< 7. count number of 1's in a 32 bit integer.(i had not remembered whether array or integer). 8. main(){ char *s1 = "hello",*s2 ="abce"; strcpy(s1,"");
s2[0] = s1[0];
printf("%d%d",strlen(s1),strlen(s2));
} 9. regarding memset
10.Algorithm to delete a node in Double linked list. 11. Difference b/n fgets,fscanf which u will prefer.
Unix
11.What is creon and whats diff b/n 'at' command. 12. what is system call and lib function. whats diff b/n them. abt execve - expalin. 13.some thing abt makeall 14. write abt TCP,IP,ICMP
Ubinetics Test Pattern- July 2003
20 c objective Qs to be answered in 30 minutes All questions are related to basic c concepts like expression, arrays, loops ,structure , pointers around 3 or 4 qs on array with loops
Since paper is very easy cutoff is very high.
They will select 20% of the student for the interview after written test. Freshersworld.com
point to remember.
Each correct ans 1 marks Each wrong answer 1 -ve mark Sample Paper
Some of the questions will not have answers .Please forgive us.
1. Difference b/n scanf("%s",msg);and scanf("%[\^n]",msg); where msg is a char array. 2. What is ure of comma operator in for loop. 3. int shw(int *a){
*a = 10; /* return stmt is missing */
}
main(){
int p=3,q=4;
q = shw(&p);
printf("%d %d",p,q); }
4. which is true
a. all automatic variables are declared with in the function b. all variables are automatic c. all not declared variables are automatic d. none
5. What is recursion. Recursive prog to generate Fibonacci series . Is it a best method? 6. write 7*a interms of +,-,<< 7. count number of 1's in a 32 bit integer.(i had not remembered whether array or integer). 8. main(){ char *s1 = "hello",*s2 ="abce"; strcpy(s1,"");
s2[0] = s1[0];
printf("%d%d",strlen(s1),strlen(s2));
} 9. regarding memset
10.Algorithm to delete a node in Double linked list. 11. Difference b/n fgets,fscanf which u will prefer.
Unix
11.What is creon and whats diff b/n 'at' command. 12. what is system call and lib function. whats diff b/n them. abt execve - expalin. 13.some thing abt makeall 14. write abt TCP,IP,ICMP
Sasken Exam 20th Jul 2004
Pattern : C(10 Qs) + Aptitude(10 Qs) + Discpline based[CS/EC](10 Qs)
Duration : 1 Hr
C questions
1.Consider the following declaration:-
char const *p = 'd';
Which of the following is not a permissible operation (a) *p++ (b) ++p (c) (*p)++ (d) All
2.What is the output of the following code:-
void print_arr(float **p) { printf(" 0 %f 1 %f 2 %f\n",p[0][0],p[0][1],p[0][2]); }
void main() { float arr[2][3] = {{0,1,2},{3,4,5}}; float **fl_arr; fl_arr = (float *)arr; print_arr(fl_arr); fl_arr++; print_arr(fl_arr); }
(a) (d)segmentation fault
3.What is the output of the following code:-
- define putchar (c) printf("%c",c)
void main() { char s='c'; putchar (s); }
(a) c (b) 99 (c) Compilation error (d) Execution error
4.What is the output of the following code:-
void main() { printf("%d",printf("ABC\\")); }
(a) ABC\\ (b) 1 (c) ABC\4 (d) ABC\3
5.What is the output of the following code:-
int compute(int n) { if(n>0) { n=compute(n-3)+compute(n-1); return(n); } return(1); }
void main() { printf("%d",compute(5)); }
(a) 6 (b) 9 (c) 12 (d) 13
6.What is the output of the following code:-
void main() { int i; for(i=0;i<3;i++) { int i=100; i--; printf("%d..",i); } }
(a0..1..2.. (b)99..98..97.. (c)100..100..100.. (d)99..99..99..
7.What is the output of the following code:-
void main() { int a[]={9,4,1,7,5}; int *p; p=&a[3]; printf("%d",p[-1]); }
(a)6 (b)1 (c)7 (d)Error
8.What is the output of the following code:-
void main() { int a[]={10,20,30,40,50}; int *p; p= (int*)((char *)a + sizeof(int)); printf("%d",*p); }
(a)10 (b)20 (c)30 (d)40
9.Which code will run faster
for(i=0;i<100;i++) for(j=0;j<10;j++) a[i][j]=0;
OR
for(j=0;j<10;j++) for(i=0;i<100;i++) a[i][j]=0;
(a)First code (b)Second code (c)Same (d)Compiler and hardware dependent
Aptitude
1.How many 2 digit numbers are there which have 8 as the unit number in it's square. (a)3 (b)None (c)2 (d)1
2. B is 8km East of A. C is 6km North of B. D is 12km East of C. E is 16km North of D. What is the distance b/w A and E. (a)20km (b)22km (c)18km (d)30km
3. x+y = z Then (a)... (b)y<Z (c)...
4. 2<X<y<8 Then which is the greatest (a) (x^2)y (b) 5xy (c) x(y^2) (d) 5(x^2)y/12
5. A is taller than B, D is taller than D, D is shorter than E.Then which of the following is correct. (a) C is taller than E (b) A is taller than C (c) D is shorter than A (d) B is shorter than C
6.A small passage was given and 4 options which summarizes it was given.The best was to be chosen.
7.Another passage was given and 4 inference was given and correct was to be chosen.This one is very easy.
8.Which of the following is a parellogram:- (a)130,50,130,50(angle in deg) (b)120,30,130,20 (c)90,90,90,90 (d)a & c
9. In the following series (an - 1)^2, 1 is the first term.Which are the next three (a)1,3,4 (b)0,3,6 (c)0,1,2 (d)0,1,0
Computer science
1.Deadlock occur when (a)Some resources are held up by some process. (b)... (c)... (d)None of these
2. A prefix expression can be equal to a postfix expression reversed only if (a)It is left associative (b)It is commutative (c)It is right associative
3.How many lines will be printed in the following Pascal pgm [I don't remember the Pascal version,so I am giving C version]
void print(int n) { if(n>0) { print(n-1); printf("%d",n);//println(n) in Pascal version. print(n-1); } } (a)3 (b)7 (c)15 (d)31
4.Maximum number of nodes in a tree with n levels. (a)2^(n-1) (b)(2^n)-1 (c)2^(n-1) - 1
5.Complete graphwith n nodes have (a)n-1 edges (b)n(n-1)/2
6.If d is the degree of a node in a graph and n is number of vertices then number of edges in that graph is (a)Edi^n (b)0.25Edi (c)0.5Edi
7.A grammar was given and 4 strings was given and the one which was not possible was to be chosen.
8.A problem related to ethernet in which a station sending a frame is of p probablity.There are m stations to send pckts.4 option was given.It was a mathematical kind of question related to probablity.
9.Which of the following layer in the OSI model does error handling (a)Data link (b)Network (c)Transport (d) a & c
10.A network problem in which Data rate,Propagation delay,and distance was given and it was to find how many packets will be in the line. Choices where (a)5000 (b)Not possible to find with given data (c)1000
A
Interview [For CS students]
There is Tech as well as HR interview. Tech interview is the important one.
Tech interview questions
They will ask about the project.They will ask general questions about it and most probably will not go into the implementation part of it.So one must have a general idea about the project done.
Interview is mainly based on Data Structures.Some questions are as follows:- - What is a tree,its application,order for insertion,deletion and traversal with worst case analysis. - What is a graph,its application. - Height of a tree - Balanced tree and how to balance a tree - Minimum Spanning Tree - Dijikstra's, Prim algorithms - Define a structure for a linked list. - Binary search and its analysis - Heap sort and its analysis - What is a heap and its application - Cache and its working - Memory(IO mapped) - Recursive fns and types, its adv and disadv. - Compiler(grammar)
-
-
-
-
- C debugging questions like
-
-
-
(1)What is the problem with the following code
int * f(int a) { int i; i=a; return(&i); } Ans-> We can't return address of auto variable as it is allocation is made in stack which is deallocated when the function returns.
(2) a.h b.c c.c d.c int i=0 #include"a.h" #include"a.h" extern int i;void main{.....} | | | b.o c.o d.o Compilation Phase
Linked to get exe. Will there be any problem in any phase.If yes then where and what? In linking phase as there will be multiple declaration of i.
-
-
-
-
- You will be told to write some code like
-
-
-
(1)To find string length by using recursive function. (2)To find fibonaci series by using recursive function. (3)To write code for malloc so that allocation may be made fastly. (4)Write a fn prototype which return a pointer which points to an array of 10 ints.
HR Interview
- Introduce yourself - Why should we take you - What you know about Sasken and etc.
Sample Test Paper
Technical Questions
1. main()
{
char **p=="Hello";
printf("%s",**p);
}
Ans: Garbage or nothing
2. main()
{
printf("%d%c\n");
printf("%d%c\n");
}
Ans: Garbage Value
3. main()
{
int x==5;
printf("%d%d",x++,++x);
}
Ans==6 6
4. main()
{
int x==4;
printf("%d",printf(" %d %d ",x,x) );
}
Ans: 4 4 5
5. main()
{
union
{
int i;
char p;
struct
{
int t;
char e;
char o;
}w;
};
printf("%d\n",sizeof(l) );
}
Ans: 4
6. main()
{
int i==0,n==6;
while(n--0);
i+==n;
printf("%d\n",i);
}
Ans: -1
7. ain()
{
char a[]=="Hello";
printf("%c\n",*a++);
}
Ans: Error
8. a=3,b=2,c=1;
What's the value of k?
k== a< b < c-1;
Ans: 0
9. main()
{
int a=3;
do
{
printf("%d", a);
a=-1;
} while(a0);
}
Ans: 3
10. It is not "exact" Question; But the given Answers is:
a) PASS1 PASS2
b) PASS1 FAIL1
c)FAIL1 FAIL2
d)FAIL1 PASS2
main()
{
char c==-32;
int i==-64;
unsigned u==-26;
if(ci)
printf("PASS1");
if( i < c)
printf("PASS2");
else
printf("FAIL1");
if(i<U)
printf("PASS2");
else
printf("FAIL2");
}
Ans: PASS1 PASS2 PASS1
11. main()
{
int i==0;
for( i==0; i<= ;i++)
{
switch(i)
{
case 0: i+==5;
case 1: i+==2;
case 2: i+==5;
default: i+==4;
break;
}
printf("%d",i);
}
Ans: 16 21
12. main()
{
int i==4;
switch(i)
{
case 1:
printf("HEllo"):
case default: // "case" should not come with "default"
printf("****");
}
}
Ans: Error
13. main()
{
int sum==0,count;
for(count==1;sum+==count)
printf("%d\t",sum);
}
Ans: Error
14. define cond(a) a=e && a<=0
main()
{
char s=='R';
if( cond(s) )
printf("UPPER CASE");
else
printf("LOWER CASE");
}
Ans:UPPER CASE
15. main()
{
static int i==5;
printf("%d\t",i--);
if( i)
main();
}
Ans: 5 4 3 2 1
16. main()
{
char *a1=="new",*a2=="dictionary",*t;
swap(a1,a2);
printf("(%s%s)",a1,a2);
t=¡;
a1=¢;
a2==t;
printf("-(%s%s)",a1,a2);
}
swap( char *s1,char *s2)
{
char *temp;
s1=s2;
s2=s1;
temp=s1;
}
Ans: (newdictionary)-(dictionarynew)
17. *p++?
Ans: increments Address
18. main()
{
int a[]=={ 10,20,30,40,50};
char*p==(char*)a;
printf("%d", * ( (int *) p+4);
}
Ans: 50
19. one question nothig but calling a function before it has been defined.
Optimize the below 1,2,3,4 questions for time:
1) int i; if i=0 then i:=1; if i=1 then i:=0;
2) int i; if i=0 then i:=1; if i=1 then i:=0; (given that i can take only two values (1,0))
3) int i; if i=0 then i:=1; else if i=1 then i:=0; (given that i can take only two values (1,0))
4) int m,j,i,n; for i:=1 to n do m:=m+j*n
5) Expand the following a) ISDN b) CASE c) CSMA/CD d) OOPS e) MIMD
6) In the following questions, answer A,B,C,D depending on when the errors are detected? A if no error is detected B if semantic and syntactic checking C if during Code genration & Symbol allocation D run time
a) Array overbound b) Undeclared identifier c) stack underflow d) Accessing an illegal memory location
7) How many page faults will occur for below sequence of pages when LRU page replacement algorithm is used ( The memory can only have 3pages):
1,2,3,4,2,1,5,2,4 (something like that)
MOTOROLA PSGTECH 2003 There were basically 3 papers -software ,DSP, Semiconductor software paper (20 questions 45 minutes) concentrate more on data structures 10 questions from data structures and 10 from C++ and data structures10 questions were in the fill in the blank format and 10 questions were multiple choice questions.
1. bubble sorting is a)two stage sorting b)..... c).... d)none of the above
2. .c++ supports a) pass by value only b) pass by name c) pass by pointer d) pass by value and by reference
3. .Selection sort for a sequence of N elements no of comparisons = _________ no of exchanges = ____________
4. Insertion sort no of comparisons = _________ no of exchanges = ____________
5. what is a language? a) set of alphabets b)set of strings formed from alphabets c)............ d)none of the above
6. Which is true abt heap sort a)two method sort b)has complexity of O(N2) c)complexity of O(N3) d)..........
7. In binary tree which of the following is true a)binary tree with even nodes is balanced b)every binary tree has a balance tree c)every binary tree cant be balanced d)binary tree with odd no of nodes can always be balanced
8. Which of the following is not conducive for linked list implementation of array a)binary search b)sequential search c)selection sort d)bubble sort
9. In c++ ,casting in C is upgraded as a)dynamic_cast b)static_cast c)const_cast d)reintrepret_cast
10. Which of the following is true abt AOV(Active On Vertex trees) a)it is an undirected graph with vertex representing activities and edges representing precedence relations b)it is an directed graph "" "" """ "" "" "" "" "" " c)........ d).......
11. Question on worst and best case of sequential search
12. question on breadth first search
13. char *p="abcdefghijklmno" then printf("%s",5[p]);
14. what is the error struct { int item; int x;} main(){ int y=4; return y;} error:absence of semicolon
15. Which of the following is false regarding protected members a)can be accessed by friend functions of the child b) can be accessed by friends of child's child c)usually unacccessible by friends of class d) child has the ability to convert child ptr to base ptr
16. What is the output of the following void main() { int a=5,b=10; int &ref1=a,&ref2=b; ref1=ref2; ++ ref1; ++ ref2; cout<<a<<b<<endl; } value of a and b a)5 and 12 b)7 and 10 c)11 and 11 d)none of the above
17. What does this return f(int n) { return n<1?0:n==1?1:f(n-1)+f(n-2) } hint:this is to generate fibonacci series code for finding out whether a string is a palindrome,reversal of linked list, recursive computation of factorial with blanks in the case of some variables.we have to fill it out
18. for eg; for palindrome palindrome(char * inputstring) { int len=strlen ( ?); int start= ?; end =inputstring + ?-?; for(; ?<end && ?==?;++ ?,--?); return(?==?); } we have to replace the question marks(?) with corresponding variables
19. .linked list reversal Linked (Link *h) { Link *temp,*r=0,*y=h; while(y!= ?) (ans:Null) { temp = ?;(ans:y->next) some code here with similar fill in type }
20. fill in the blanks type question involving recursive factorial computation
C-Dac Sample quesion paper - pattern 1 Fundamentals of Programming 1.The programming language that was designed for specifying algorithm Address ASCII ALGOL None of these options
2. _____ contains the addresses of all the records according to the contents of the field designed as the record key. Index<------ans Subscript Array File
3. _________ symbol is used for Processing of data. Oval Parallelogram<------ans Rectangle Diamond
4. __________ is the analysis tool used for planning program logic Protocol None of these options PROLOG Pseudocode
5. Machine language has two part format the first part is__________ and the second part is __________ OPCODE,OPERAND<------ans OPERAND,OPCODE DATA CODE,OPERAND OPERAND,CODEOP
6. Language Primarily used for internet-based applications ADA C++ JAVA;------ans FORTRAN
7. _________ is a point at which the debugger stops during program execution and awaits a further command. Memory Dump Watch point<------ans Break point None of these options 8. ________do not contain any program logic and are ignored by the language Processor Protocol Virus Comment None of these options
9. The component of data base management system is ________ Data definition Language Data manipulation Language Data definition Language and Data manipulation Language None of these options 10. The quality of Algorithm is judged on the basis of_________ Time requirement Memory Requirement Accuracy of solution All of these options<------ans
11. Advantages of using flow charts is Effective Analysis Efficient Coding Time consuming Effective Analysis and Efficient Coding<-----ans
Programming in C 12. The Real constants in C can be expressed in which of the following forms Fractional form only Exponential form only ASCII form only Both Fractional and Exponential forms<------ans
13. The program, which translates high-level program into its equivalent machine language program, is called Transformer Language processor Converter None of these options<------ans
14. Consider the following statements. i.Multiplication associates left to right ii.Division associates left to right iii.Unary Minus associates right to left iv.subtraction associates left to right All are true <------ans only i and ii are true all are false only iii and iv are true 15. What will be the value of variable a in the following code? unsigned char a; a = 0xFF + 1; printf("%d", a); 0xFF 0x100 0 <------ans 0x0
16. What is the output of the following program?
- include <stdio.h>
void main() { printf("\n10!=9 : %5d",10!=9); } 1<------ans 0 Error None of these options 17. #include<stdio.h> void main() { int x=10; (x<0)?(int a =100):(int a =1000); printf(" %d",a); } Error<------ans 1000 100 None of these options 18. Which of the following shows the correct hierarchy of arithmetic operations in C (), **, * or /, + or - (), **, *, /, +, - (), **, /, *, +, - (), / or *, - or + <-----Ans
19. What is the output of the following code?
- include<stdio.h>
void main() { int a=14; a += 7; a -= 5; a *= 7; printf("\n%d",a); } 112<------ans 98 89 None of these options
20. What is the output of the following code? #include<stdio.h>
- define T t
void main() { char T = `T`; printf("\n%c\t%c\n",T,t); } Error T t T T t t
21. The statement that prints out the character set from A-Z, is for( a = `z`; a < `a`; a = a - 1) printf("%c", &a); for( a = `a`; a <= `z`; a = a + 1 printf("%c", &a); for( a = `A`; a <= `Z`; a = a + 1)<----Ans printf("%c", a); for( a = `Z`; a <= `A`; a = a + 1) printf("%c", a); 22. The statement which prints out the values 1 to 10 on separate lines, is for( count = 1; count <= 10; count = count + 1) printf("%d\n",count); for( count = 1; count < 10; count = count + 1) printf("%d\n",count);<------ans for( count = 0; count <= 9; count = count + 1) printf("%d ",count); for( count = 1; count <> 10; count = count + 1) printf("%d\n",count); 23. What does the term `call-by-reference` refer to? Passing a copy of a variable into a function. Passing a pointer to a variable into a function. <------ans Choosing a random value for a variable. A function that does not return any values.
24. What is the output of the following code? #include<stdio.h> void swap(int&, int&); void main() { int a = 10,b=20; swap (a++,b++); printf("\n%d\t%d\t",a, b); } void swap(int& x, int& y) { x+=2; y+=3; } 14, 24 11, 21 <------ans 10, 20 Error 25. What is the output of the following program code
- include<stdio.h>
void abc(int a[]) { a++; a[1]=612; } main() { char a[5]; abc(a); printf("%d",a[4]); } 100 612 Error<------ans None of these options 26. which of the following is true about recursive function i. it is also called circular definition ii. it occurs when a function calls another function more than once iii. it occurs when a statement within the function calls the function itself iv. a recursive function cannot have a return statement within it" i and iii<------ans i and ii ii and iv i, iii and iv 27.What will happen if you assign a value to an element of an array whose subscript exceeds the size of the array? The element will be set to 0 Nothing, its done all the time Other data may be overwritten Error message from the compiler
28. What is the output of the following code? #include<stdio.h> void main() { int arr[2][3][2]={{{2,4},{7,8},{3,4},}, {{2,2},{2,3},{3,4}, }}; printf("\n%d",**(*arr+1)+2+7); } 16 <------ans 7 11 Error 29. If int s[5] is a one dimensional array of integers, which of the following refers to the third element in the array?
- ( s + 2 ) <------ans
- ( s + 3 )
s + 3 s + 2
30. #include"stdio.h" main() { int *p1,i=25; void *p2; p1=&i; p2=&i; p1=p2; p2=p1; printf("%d",i); } The output of the above code is : Program will not compile <------ans 25 Garbage value Address of I 31. What is the output of the following code? void main() { int i = 100, j = 200; const int *p=&i; p = &j; printf("%d",*p); } 100 200 <------ans 300 None of the above
32. void main() { int i=3; int *j=&i; clrscr(); printf("%d%d",++*j,*(&i)); } What is the output of this program? 3 3 4 3 <------ans 4,address of i printed Error:Lvalue required 33. What is the output of the following code? #include<stdio.h> void main() { int arr[] = {10,20,30,40,50}; int *ptr = arr; printf("\n %d\t%d\t",*ptr++,*ptr); } 10 20 10 10<------ans 20 20 20 10
34. Which of these are reasons for using pointers? 1.To manipulate parts of an array 2.To refer to keywords such as for and if 3.To return more than one value from a function 4.To refer to particular programs more conveniently 1 & 3 <------ans Only 1 Only 3 All of the above
35. struct num { int no; char name[25]; }; void main() { struct num n1[]={{25,"rose"},{20,"gulmohar"}, {8,"geranium"},{11,"dahalia"}}; printf("%d%d" ,n1[2].no,(*&n1+2)->no+1); } What is the output of this program? 8 8 8 9 <------ans 9 8 8 , unpredictable 36. During initializing a union
Only one member can be initialised. All the members will be initialised. Initialisation of a union is not possible.<------ans None of these options 37. Self referential structure is one a. Consisting the structure in the parent structure b. Consisting the pointer of the structure in the parent structure Only a Only b Both a and b Neither a nor b 38. Individual structure member can be initialized in the structure itself True False Compiler dependent None of these options
39. Which of the following is the feature of stack? All operations are at one end It cannot reuse its memory All elements are of different data types Any element can be accessed from it directly<------ans 40. When stacks are created Are initially empty<------ans Are initialized to zero Are considered full None of these options
41. What is time required to insert an element in a stack with linked implementation? (1) (log2n)<------ans (n) (n log2n)
42. Which of the following is the feature of stack? All operations are at one end It cannot reuse its memory All elements are of different data types Any element can be accessed from it directly<------ans 43. Time taken for addition of element in queue is (1) (n) (log n)<------ans None of these options 44. When is linear queue said to be empty ? Front==rear Front=rear-1 Front=rear+1 Front=rear<------ans
45. When queues are created Are initially empty<------ans Are initialized to zero Are considered full None of the above
46. What would be the output of the following program?
- include <stdio.h>
main() { printf("\n%c", "abcdefgh"[4]); } abcdefgh d e <------ans error
47. Select the correct C code which will read a line of characters(terminated by a \n) from input_file into a character array called buffer. NULL terminate the buffer upon reading a \n.
int ch, loop = 0; ch = fgetc( input_file ); while( (ch != `\n`)&& (ch != EOF) ){buffer[loop] = ch; loop++; ch = fgetc(input_file );} buffer[loop] = NULL;
int ch, loop = 0; ch = fgetc( input_file ); while( (ch = "\n")&& (ch = EOF)) { buffer[loop] = ch; loop--; ch = fgetc(]input_file ); } buffer[loop]= NULL; int ch, loop = 0; ch = fgetc( input_file ); while( (ch <> "\n")&& (ch != EOF) ) { buffer[loop] = ch; loop++; ch = fgetc(input_file ); } buffer[loop] = -1; None of the above 48. What is the output of the following code ? void main() { int a=0; int b=0; ++a == 0 || ++b == 11; printf("\n%d,%d",a,b); } 0, 1 1, 1 <------ans 0, 0 1, 0
49. What is the output of the following program? #define str(x)#x
- define Xstr(x)str(x)
- define oper multiply
void main() { char *opername=Xstr(oper); printf("%s",opername); } opername Xstr multiply <------ans Xstr
50. What is the output of the following code ? #include<stdio.h>
- include<string.h>
void main() { char *a = "C-DAC\0\0ACTS\0\n"; printf("%s\n",a); } C-DAC ACTS ACTS C-DAC <------ans None of these
51. #include<stdio.h> void main() { while (1) {if (printf("%d",printf("%d"))) break; else continue; } } The output is Compile time error Goes into an infinite loop Garbage values <------ans None of these options 52. Select the correct C statements which tests to see if input_file has opened the data file successfully.If not, print an error message and exit the program. if( input_file == NULL ) { printf("Unable to open file.\n");exit(1); }
if( input_file != NULL ) { printf("Unable to open file.\n");exit(1); } while( input_file = NULL ) { printf("Unable to open file.\n");exit(1);} None of these options 53.The code int i = 7; printf("%d\n", i++ * i++); prints 49 prints 56 <------ans is compiler dependent expression i++ * i++ is undefined 54. Recursive procedure are implemented by Linear list Queue Tree Stack<------ans
55. Which of these are reasons for using pointers? 1. To manipulate parts of an array 2. To refer to keywords such as for and if 3. To return more than one value from a function 4. To refer to particular programs more conveniently 1 & 3<------ans only 1 only 3 None of these options
56. The expression x = 4 + 2 % -8 evaluates to -6 6 4 None of these options
57. What is the output of the following code? #include<stdio.h> main() { register int a=2; printf("\nAddress of a = %d,", &a); printf("\tValue of a = %d",a); Address of a,2 <------ans Linker error Compile time error None of these options
58. What is the output of the following code? #include<stdio.h> void main() { int arr[]={0,1,2,3,4,5,6}; int i,*ptr; for(ptr=arr+4,i =0; i<=4; i++) printf("\n%d",ptr[-i]);(as the 0=4,for -1 it becomes =3) } Error 6 5 4 3 2 0 garbage garbage garbage garbage 4 3 2 1 0 <------ans
59. Which of the following is the correct way of declaring a float pointer: float ptr; float *ptr; <------ans
- float ptr;
None of the above 60.If the following program (newprog) is run from the command line as:newprog 1 2 3 What would be the output of the following? void main (int argc, char*argv[]) { int I,j=0; for (I=0;I<argc;I++) j=j + atoi(argv[I]); printf("%d",j); } 123 6 123 Compilation error<------ans
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:
This is the oracle paper held on July 13 2003 at NITK Surathkal. The test has 2 sections : 30 technical and 30 aptitude and 60 min time. Technical section: its very easy any one can answer 25 qns without preperation. some are
1. How compiler treats variables of recursive functions
2. What is orthogonal matrix?
3. Given two tables and asked 2 qns on those table ,
4. One is on join and another is on NOT IN
5. Given some qns on pointers( pretty easy)
6. Given five qns on data structures like , lifo, fifo
7. Qtn on primary key
8. How NULL in sql is treated?
9. Given a doubly linked list and asked r->left->right->data ans: r->data
10. Explain const char *ptr and char *const ptr
11. Remaining i didn`t remember
Technical
12. What is the output of the following program?<?xml:namespace prefix = o ns urn:schemas -microsoft-com office:office" "
#include<stdio.h>
#include<math.h>
void main( )
{
int a=5,b=7;
printf(“%d\n”,b\a);
}
A. 1.4
B. 1.0
C. 1
D. 0
13. What is the output of the following program listing?
- include<stdio.h>
void main ( )
{
int x,y:
y=5;
x=func(y++);
printf(“%s\n”,
(x==5)?”true”;”false”);
}
int func(int z)
{
if (z== 6)
return 5;
else
return 6;
}
A True B false C either a or b D neither a nor b
14. What is the output of the following progarm?
#include<stdio.h>
main( )
{
int x,y=10;
x=4;
y=fact(x);
printf(“%d\n”,y);
}
unsigned int fact(int x)
{
return(x*fact(x-1));
}
A. 24
B. 10
C. 4
D. none
15. Consider the following C program and chose collect answer
#include<stdio.h>
void main( )
{
inta[10],k;
for(k=0;k<10;k++)
{ a[k]=k;}
printf (“%d\n”,k);
}
A. value of k is undefined ; unpredictable answer
B. 10
C. program terminates with run time error
D. 0
16. Consider the prog and select answer
#include<stdio.h>
void main ( )
{
int k=4,j=0:
switch (k)
{
case 3: j=300;
case 4: j=400:
case 5: j=500;
}
printf (“%d\n”,j);
}
A. 300
B. 400
C. 500
D. 0
17. Consider the following statements:
Statement 1 A union is an object consisting of a sequence of named members of various types
Statement 2 A structure is a object that contains at different times, any one of the several members of various types
Statement 3: C is a compiled as well as an interpretted language
Statement 4: It is impossible to declare a structure or union containing an instance of itself
A. all the statements are correct
B. except 4 all are correct
C. statemnt 3 is only correct
D. statement 1,3 are incorrect either 2 or 4 is correct
18. consider the following program listing and select the output
#include<stdio.h>
main ( )
{
int a=010,sum=0,tracker:
for(tracker=0;tracker<=a;tracker++)
sum+=tracker;
printf(“ %d\n”,sum);}
A. 55
B. 36
C. 28
D. n
19. Spot the line numbers , that are valid according to the ANSI C standards?
Line 1: #include<stdio.h>
Line 2: void main()
Line 3: {
4 : int *pia,ia;
5 :float *pafa,fa;
6 :ia=100;
7 :fa=12.05;
8 :*pfa=&ia;
9 :pfa=&ia;
10 :pia=pfa;
11 :fa=(float)*pia;
12 :fa=ia;
13 :}
a. 8 and 9
b. 9 and 10
c. 8 and 10
d. 10 and 11
20. What is the o/p of the follow pgm?
#include<stdio.h>
main()
{
char char_arr[5]=”ORACL”;
char c=’E’;
prinf(“%s\n”,strcat(char_arr,c));
}
a: oracle
b. oracl
c. e
d. none
21. consider the following pgm listing
#include<stdio.h>
main()
{
int a[3];
int *I;
a[0]=100;a[1]=200;a[2]=300;
I=a;
printf(“%d\n”, ++*I);
printf(“%d\n”, *++I);
printf(“%d\n”, (*I)--);
printf(“%d\n”, *I);
}
what is the o/p
a. 101,200,200,199 b. 200,201,201,100 c. 101,200,199,199 d. 200,300,200,100
22. which of the following correctly declares “My_var” as a pointer to a function that returns an integer
a. int*My_Var(); b. int*(My_Var()); c. int(*)My_Var(); d. int(*My_Var)();
23. what is the memory structure employed by recursive functions in a C pgm?
a. B tree b. Hash table c. Circular list d. Stack
24. Consider the follow pgm listing? Line 1: #include<stdio.h>
2: void main()
3: {
4: int a=1;
5: const int c=2;
6: const int *p1=&c;
7: const int*p2=&a;
8: int *p3=&c;
9: int*p4=&a;
25. what are the lines that cause compilation errors?
a. 7 b. 8 c. 6 and 7 d. no errors
26. what will be the o/p
#include<stdio.h>
main()
{
inta[3];
int *x;
int*y;
a[0]=0;a[1]=1;a[2]=2;
x=a++;
y=a;
printf(“%d %d\n”, x,(++y));
}
a. 0,1
b. 1,1
c. error
d. 1,2
what is the procedure for swapping a,b(assume that a,b and tmp are of the same type?
a. tmp=a; a=b;b=temp; b. a=a+b;b=a-b;a=a-b; c. a=a-b;b=a+b;a=b-a; d. all of the above
Cadance Sample Question Paper
Technical
1. In assembler relocatable code generated by ...!!?? asn: indirect addressing
2. int v,u; while(v != 0)
{
t = v % u;
v = u;
u = t;
} find the time complexity of the above program.
3. x is passed by reference, y passed by value. x = 3, y = 2; foo(x, y) var integer x, y;
{
x = x + 2;
y = y + 3;
}
main()
{
x = 5;
y = 5;
foo(x, y);
print (x, y);
} output of the above pseudo code.
4. How many flip flops you require for modulo 19 counter.
5. ring counter's initial state is 01000. after how many clock cylces will it return to the initial state.
6. some boolesn expression of the form x'y'z' + yz + .. ( something like this) find the simplified expression
7. given 6 bit mantissa in 2s complement form and 4 bit exponent is in excess-4 form in a floating point representation, find the number ans -(something) * ( 2 to the power 3)
8. A signed no is stored in 10-bit register, what is the max and min possible value of the number.
Aptitude
1. log( X**3 + Y**3) where x=3/4 y=1/4 log(3) , log(7) & log(2) is given ...
ans:-0.385
2. last question of paper .. sum of money of A & B =Rs.10 diffrence of A + B = Rs.9
ans : 50 pesa
3. one paper is equlely folded 50 times... what is new thikness of paper.. ans: 2**50
4. connect nine point without take-off pen & without overlapping line segment 1 2 3 4
- * * 5
- * * 6
0* * * 7 ans: start with 0 to 1 to 7 to 0 to 4 .
5. A room is 30 X 12 X 12. a spider is ont the middle of the samller wall, 1 feet from the top, and a fly is ont he middle of the opposite wall 1 feet from the bottom. what is the min distance reqd for the spider to crawl to the fly.
6. A man while going dowm in a escalator(which is miving down) takes 50 steps to reach down and while going up takes 125 steps. If he goes 5 times faster upwards than downwards. What will be the total no of steps if the escalator werent moving.
7. 2/3 of corckery(plates) are broken, 1/2 have someother thing(handle) broken , 1/4 are both broken and handle broken. Ultimately only 2 pieces of corckery were without any defect. How many crockery were there in total.
8. It is difficult to draw a figure but another question was in which some NAND and OR gates were given. ans - Z = true.
Question Consist of 4 parts. Duration of exam is 60 min.
· C---------20Q
· C++ ----15Q
· Unix-----15Q
· Apptitude--15Q
C And C++
1. i=23, j=4, c=0; c=i++-++j; o/p?
2. #define CUBE(x) x*x*x
- define MUL3(x,y) 3*x*y
- define ADD(x) x+y
some statement maikng use of the preprocessors defined above............find o/p.
3. virtual destructors r used for ?
4. 2 questions on friend functions & classes
5. char c[]="123456789";
i=4;
printf("%c %c", c[i], i[c]); o/p? one more question on these lines.
6. int *ptr;
p=0;
p++;
printf("%u", p);
o/p?
a. 0 b. garbage value c. 4 d. none of the above
7. double i=0.0;
switch(i)
{
case 0.0:
printf("jgdj");
case 1.0:
printf("ptoy");
break;
default:
printf("hdfv");
} o/p?
8. volatile int i; in d above statement, is "volatile" a. a type declaration b. type qualifier c. storage class d. none of the above
Unix
1. "bash" is a kind of shell in UNIX
2. primitive flavours of unix options : a. BSD &Sys V b. LINUX & BSD c..
3. which of the folllowing is used 4 redirection in UNIX? >, |, <, ^
4. wot is d UNIX terminology 4 multi-tasking? a. time slicing b. pre-emptive ....... c. time division d.......
5. In UNIX if You try accessing a directory for which u dont have permission, wot message is displayed? a. permission denied b. invalid user c. access denied d.........
MODE: CAMPUS COLLEGE: Government Engineering College, Aurangabad RECRUITMENT FOR: Development/Testing
The test consisted of a 1hr technical objective questions and 1hr ,Programming test. Tech. Qs There were six sections and each consist of 5qs.
A. Computer Algorithms 1. Time Complexity 2. Which of the following cannot be implemented efficiently in Linear Linked List 1. Quicksort 2. Radix Sort 3. Polynomials 4. Insertion Sort 5. Binary Search 3. In binary search tree , n=nodes, h=height of tree. What's complexity? 1. o(h) 2. o(n*h) 3. o(nLogn) 4. o(n*n) 5. None 4. 5.
B. C Programs 1. Printf("%d%d",i++,i++); 1. Compiler Dependent 2. 4 4 3. 4 3 4. 3 4 5. None of Above 2. void main() { printf("persistent"); main(); } 1. Till stack overflows 2. Infinite 3. 65535 4. 34423 5. None 3. Swapping 4. what does it do? void f(int n) {
if(n>0)
{
if(A[i]>A[j]) swap();
}
else f(n-1);
} 1. Swap 2. Sort in Ascending order 3. Sort in Descending order 4. Computes permutation 5. 5. Given a Fibonacci function f1=1;f2=1 fn=f(n-1)+f(n-2) which of the following is true? 1. Every Second element is even 2. Every third element is odd 3. The series increases monotonally 4. For n>2, fn=ceiling(1.6 * f(n-1)) 5. None
C. Operating System 1. Where the root dir should be located 1. Anywhere on System disk 2. Anywhere on Disk' 3. In Main memory 4. At a fixed location on Disk 5. At fixed location on System Disk 2. Problem on Concurrency 3. Problem on Round Robin Algorithm 4. 5.
D. General 1. If x is odd, in which of the following y must be even 1. X+Y=5 2. 2(X+Y)=7 3. 2X + Y =6 4. X+2Y=7 5. 2. 1000! How many digits? What is the most significant and Least significant
digit 3. 4. 5.
E. Theory 1. If a production is given S -> 1S1 0S0 00 11 Then which of the following is invalid 1. 00101010100 2. 3. 4. 5. 2. Context free grammar cannot recognize 1. if-then-else 2. var 3. loops 4. syntax 5. None 3. 4. 5.
F. DBMS 1. If table A has m rows and table B has n rows then how many rows will the following query return SELECT A.A1,B.B1 FROM A,B WHERE A.A3=B.B3 1. <=(m*n) 2. m*n 3. <=(m+n) 4. >=(m+n) and <=(m*n) 5. m+n 2. A Query optimizer optimizes according to which of the following criteria 1. Execution time 2. Disk access 3. CPU usage 4. Communication time 5. None 3. Which of the following is not a characteristic of a transaction 1. Atomicity 2. Consistency 3. Normalization 4. Isolation 5. Durability 4. The def. of Foreign key is there to support 1. Referential integrity 2. Constraint 3. 4. 5. None 5. Problem Process A Process B WRITELOCK(X) WRITELOCK(Y) READ(X) READ(Y) ... ... 1. The problem is serializable 2. The problem is not serializable 3. It can be run in parallel 4. 5. None
PROGRAMMING SECTION (This consisted of Two programs to be solved in 1 hour.)
A sparse matrix is a matrix in which a node with val=0 is not represented. The whole matrix is represented by a Linked list where node typedef struct Node {
int row; int col; int value; sparsematrix next;
} Element, *sparsematrix; The problem is, if there are two matrix given suppose m1 and m2, then add them and return the resultant sparsematrix.
If suppose there are N functions say from 0,1,2,... N-1 and it's given that A[i][j]=1 if the function i contains a call to
func. j otherwise A[i][j]=0, then write a function that will form groups of related functions and print them line by line and at the end print the number of total groups
COMPUTER SYSTEM ARCHITECTURE
4TH SEM COMPUTER SCIENCE
1-Describe the memory hierarchy of the computer system.The access time of cache memory is 100ns and that of main memory 1000ns.It is estimated that 80 percent of the memory request for read and the remaining 20 percent for write.The hit ratio for read accesses only 0.9.A write through procedure is used.
(i) What is the average access time of the system considering only memory read cycles.
(ii) What is the average access time of the system for both read and write requests.
(iii) What is the hit ratio taking into consideration the write cycle.
2-Explain in detail different addressing modes.A two word instruction is stored in memory at an address designated by the symbol W.The address field of the instruction(stored at W+1)is designated by the symbol Y.The operand used during the execution of the instruction is stored at an address symbolized by Z.An index register contains the value X.State how Z is calculated from other addresses if the addressing mode of the instruction is-
(i)Direct
(ii)indirect
(iii)relative
(iv)indexed
3-Explain the difference between hardwired control and microprogrammed control.Is it possible to have a hardwired control associated with a control memory?
4- Explain in brief micro instruction format
5- Explain decimal division with the help of flow chart?
6- Draw the diagram of memory connection to CPU and explain in brief.
7- Explain memory hierarchy
8- Explain the instruction cycle with an example.
9- With a neat diagram explain the microprogrammed control unit.
10- Explain with a proper block diagram how non restoring binary division is performed.
11-Explain the Cache memory principles.
12- Show the Flynn’s classification of parallel processing?
13- Explain Virtual memory?
14-Write down the short notes-
1-Instruction Set
2-Instruction Formats
15-Descibe the CPU Organization in brief.
16- Descibe the Multiplier control unit in brief.
17-Explain the memory device characteristics in brief.
18-A) How many 128*1 RAM chips are needed to provide a memory capacity of 2048 bytes?
B) How many lines of the of the address bus must be used to access 2048 bytes of memory ? How many of these lines will be common to all chips?
C) How many lines must be decoded for chip select ?
19- A two- way set associated cache memory uses blocks of four words. The cache can accommodate a total of 2048 words from main memory. The main memory size is 128K*32.
A) Formulate all pertinent information required to construct the cache memory.
B) What is the size of the cache memory?
20- With a neat diagram explain the single bus and two bus organization of digital computer.
Good Luck To All of You
© 2007 Kapil K Nagwanshi
NIT-RR

