QUINNOX Profile
Quinnox is a leading IT consulting company focused on providing business relevant solutions to its customers. We offer the entire range of enterprise IT services - package implementation, web enablement, application integration and application management to customers in the BFSI, Manufacturing and Retail verticals.
Headquartered in the US, Quinnox has a presence across four continents. We leverage the time-tested global delivery model to carry out IT consulting, development and implementation engagements for our global clients spread across 38 countries. We have three delivery centers in India and have successfully executed several hundred engagements since inception.
For more details visit www.quinnox.com
Showing posts with label Quark. Show all posts
Showing posts with label Quark. Show all posts
Sunday, June 8, 2008
paper 2
Directions for question nos. 1-2: Eighty Five children went to amusement park where they
could ride on merry go-round roller coaster and Ferris wheel .It was known that 20 of them
have took all three rides and 55 of them have taken at least two of the three rides. Each ride
cost Rs.1 and the total receipt of the amusement park was Rs.145.
1) How many children did not try any of the rides. ?
A) 5 B) 10 C) 15 D) 20
Ans. 15.
20 kids * 3 rides = Rs. 60
(55-20=)35 kids * 2 rides = Rs. 70
60 + 70 = Rs. 130
So, Rs. (145 130 = ) 15 are left for the other (85 55 = ) 30 kids . so only 15 of
them can take a ride and rest 15 will be left out.
145 rides were taken. 20 of them took all three, i.e. Rs. 60 were spent, so 145-60= Rs. 85
are left for the others. Total kids were 85, so rest were 65. out of these 65,
2) How many children took exactly one ride?
A) 5 B) 10 C) 15 D) 20
Ans.
15
3) Four cities are connected by a road network as shown in the figure. In how many ways can
you start from any city and come back to it without travelling on the same road more than
once ?
A) 8
B) 12
C) 16
D) 20
Ans. 12.
Consider the top city, the following are the 3 routes possible, starting from the leftmost edge.
Since there are 3 edges emanating from each city and the figure is perfectly symmetrical,
these 3 routes are possible from each edge, hence for any given city, the total number of
routes = 4 * 3 = 12.
Directions for question nos 4-5:
A, B, and C are three numbers, Let
@(A, B)= Average of A and B
*(A, B)=Product of A and B
/(A, B)=A divided by B
4) If A=2 and B=4 the value of @( / (*(A,B),B),A) would be
A) 2
B) 4
C) 6
D) 16
Ans. 2
5) Sum of A and B is given by
A) *(@(A, B), 2)
B) /(@(A,B),2)
C) @(*(A,B),2)
D) @(/(A,B),2
Ans. A.
6) Let x<0, 0 < y<1, Z>1 which of the following is false:
A) (x2-z2)has to be positive.
B) yz can be less than one.
C) xy can never be zero
D) (y2-z2) is always negative
Ans. A.
7) If As income is 25% less than Bs ,by what % is Bs income greater than that of A ?
A) 35%
B) 25%
C) 30%
D) None of these
Ans. D.
Directions for question nos 8-12: A professor keeps data on students tabulated by the
sex and the performance of the student. Data is kept in a computer disk, but unfortunately
some of it is lost because of a virus. Only the following could be recovered:
Performance
Total
Average Good Excellent
Male 10
Female 32
Total 30
Panic buttons were pressed but to no avail. An expert committee was formed,which decided
that the following facts were self evident:
a) Half the students were either good or excellent.
b) 40% of the students were female
c) One third of male students were average
8) How many students were both female and excellent?
A) 0
B) 8
C) 16
D) 32
Ans. A
Performance
Total
Average Good Excellent
Male 10 48
Female 32
Total 30 80
Panic buttons were pressed but to no avail. An expert committee was formed,which decided
that the following facts were self evident:
d) Half the students were either good or excellent. (implies the total of good and excellent
is 40, i.e., hall of 80)
e) 40% of the students were female (this implies that 32 is 40% of the total students,
hence total students are 80, this implies that males are 48, calculate the rest yourself)
f) One third of male students were average
9) What proportion of good students are male?
A) 0
B) 0.73
C) 0.4
D) 1.0
Ans. B.
10) What proportion of female students are good?
A) 0
B) 0.25
C) 0.50
D) 1.0
Ans. B
11) How many students are both male and good?
A) 10
B) 16
C) 22
D) 48
Ans. C
12) Among average students, what is the ratio of male to female?
A) 1:2
B) 2:1
C) 3:2
D) 2:3
Ans. D
ANALYTICAL
Directions for Questions Nos: 13 to 17
Five executives of a multinational company met in Bombay:
Mr. Ram can speak Tamil and Hindi
Mr.Sham speaks Tamil and English
Mr. Raju converses in English and Hindi
Mr.Balu speaks Telugu and Tamil quite well.
Mr.Lalu can speak Hindi and Telugu
13) Which of the following can act as a interpreter when Mr.Raju and Mr.Balu wish to confer?
Mr.Ram Only
Mr.Sham Only.
Either Mr.Ram or Mr.Sham
Any of the other three executives.
Ans. D
14) Besides Mr. Lalu, which of the following can converse with Mr.Balu without an Interpreter?
A) Mr.Ram Only
B) Mr.Sham only
C) Mr.Ram and Mr.Sham
D) Mr.Raju Only
Ans. C
15) Which of the following cannot converse without interpreter?
Mr. Sham and Mr.Lalu.
Mr. Ram and Mr. Sham
Mr. Ram and Mr. Raju
Mr. Sham and Mr. Balu
Ans. A
16) If a sixth executive is brought in, for him to be understood by the maximum number of original
five, he should be fluent in?
A) English and Telugu
B) Hindi and Tamil
C) Telugu and Hindi
D) Hindi and English
could ride on merry go-round roller coaster and Ferris wheel .It was known that 20 of them
have took all three rides and 55 of them have taken at least two of the three rides. Each ride
cost Rs.1 and the total receipt of the amusement park was Rs.145.
1) How many children did not try any of the rides. ?
A) 5 B) 10 C) 15 D) 20
Ans. 15.
20 kids * 3 rides = Rs. 60
(55-20=)35 kids * 2 rides = Rs. 70
60 + 70 = Rs. 130
So, Rs. (145 130 = ) 15 are left for the other (85 55 = ) 30 kids . so only 15 of
them can take a ride and rest 15 will be left out.
145 rides were taken. 20 of them took all three, i.e. Rs. 60 were spent, so 145-60= Rs. 85
are left for the others. Total kids were 85, so rest were 65. out of these 65,
2) How many children took exactly one ride?
A) 5 B) 10 C) 15 D) 20
Ans.
15
3) Four cities are connected by a road network as shown in the figure. In how many ways can
you start from any city and come back to it without travelling on the same road more than
once ?
A) 8
B) 12
C) 16
D) 20
Ans. 12.
Consider the top city, the following are the 3 routes possible, starting from the leftmost edge.
Since there are 3 edges emanating from each city and the figure is perfectly symmetrical,
these 3 routes are possible from each edge, hence for any given city, the total number of
routes = 4 * 3 = 12.
Directions for question nos 4-5:
A, B, and C are three numbers, Let
@(A, B)= Average of A and B
*(A, B)=Product of A and B
/(A, B)=A divided by B
4) If A=2 and B=4 the value of @( / (*(A,B),B),A) would be
A) 2
B) 4
C) 6
D) 16
Ans. 2
5) Sum of A and B is given by
A) *(@(A, B), 2)
B) /(@(A,B),2)
C) @(*(A,B),2)
D) @(/(A,B),2
Ans. A.
6) Let x<0, 0 < y<1, Z>1 which of the following is false:
A) (x2-z2)has to be positive.
B) yz can be less than one.
C) xy can never be zero
D) (y2-z2) is always negative
Ans. A.
7) If As income is 25% less than Bs ,by what % is Bs income greater than that of A ?
A) 35%
B) 25%
C) 30%
D) None of these
Ans. D.
Directions for question nos 8-12: A professor keeps data on students tabulated by the
sex and the performance of the student. Data is kept in a computer disk, but unfortunately
some of it is lost because of a virus. Only the following could be recovered:
Performance
Total
Average Good Excellent
Male 10
Female 32
Total 30
Panic buttons were pressed but to no avail. An expert committee was formed,which decided
that the following facts were self evident:
a) Half the students were either good or excellent.
b) 40% of the students were female
c) One third of male students were average
8) How many students were both female and excellent?
A) 0
B) 8
C) 16
D) 32
Ans. A
Performance
Total
Average Good Excellent
Male 10 48
Female 32
Total 30 80
Panic buttons were pressed but to no avail. An expert committee was formed,which decided
that the following facts were self evident:
d) Half the students were either good or excellent. (implies the total of good and excellent
is 40, i.e., hall of 80)
e) 40% of the students were female (this implies that 32 is 40% of the total students,
hence total students are 80, this implies that males are 48, calculate the rest yourself)
f) One third of male students were average
9) What proportion of good students are male?
A) 0
B) 0.73
C) 0.4
D) 1.0
Ans. B.
10) What proportion of female students are good?
A) 0
B) 0.25
C) 0.50
D) 1.0
Ans. B
11) How many students are both male and good?
A) 10
B) 16
C) 22
D) 48
Ans. C
12) Among average students, what is the ratio of male to female?
A) 1:2
B) 2:1
C) 3:2
D) 2:3
Ans. D
ANALYTICAL
Directions for Questions Nos: 13 to 17
Five executives of a multinational company met in Bombay:
Mr. Ram can speak Tamil and Hindi
Mr.Sham speaks Tamil and English
Mr. Raju converses in English and Hindi
Mr.Balu speaks Telugu and Tamil quite well.
Mr.Lalu can speak Hindi and Telugu
13) Which of the following can act as a interpreter when Mr.Raju and Mr.Balu wish to confer?
Mr.Ram Only
Mr.Sham Only.
Either Mr.Ram or Mr.Sham
Any of the other three executives.
Ans. D
14) Besides Mr. Lalu, which of the following can converse with Mr.Balu without an Interpreter?
A) Mr.Ram Only
B) Mr.Sham only
C) Mr.Ram and Mr.Sham
D) Mr.Raju Only
Ans. C
15) Which of the following cannot converse without interpreter?
Mr. Sham and Mr.Lalu.
Mr. Ram and Mr. Sham
Mr. Ram and Mr. Raju
Mr. Sham and Mr. Balu
Ans. A
16) If a sixth executive is brought in, for him to be understood by the maximum number of original
five, he should be fluent in?
A) English and Telugu
B) Hindi and Tamil
C) Telugu and Hindi
D) Hindi and English
Labels:
Quark
paper 1
Q1. __stdcall calling convention
Ans. stack is cleaned by the callee
Q2. mutable key word is used for
Ans. if used with a member variable it can be changes by a function declared as a constant
Q3. foo & const ref
Ans. this is not a good practise since references are always constants
Q4. private inheritance means
Ans Non private members of a base class become private members of derived class
Q5. int I=2;
Int j=3;
Int k=4;
Cout<<(I < j < k)
Ans. 1
Q6 #defines macro(a) ((a++) + (++a) + (a++))
Main()
{
cout << macro(1);
}
Ans. 4
Q7 string s = abcd
Char &c=s[1];
String t;
T=s;
c=z;
if(T[1]==z)
{
cout< }
else
{
cout< }
Ans. express
Q8. int func(int I)
{
static int k=0;
k++;
if( K>5)
return 1;
else
return func(I-1);
}
int main()
{
cout << func(1);
}
Ans. 1
Q9. class base
{
public:
virtual func()
{
cout < }
};
class der1: public base
{
public:
virtual func()
{
cout << DER1;
}
};
class der2: public base
{
public:
virtual func()
{
cout << DER2;
}
};
class der3: public base
{
public:
virtual func1()
{
cout << DER3;
}
};
main()
{
base *pb;
pb= new der1;
pb->func();
pb= new der2;
pb->func();
pb= new der3;
pb->func();
}
Ans: DER1DER2BASE
Q10 Which of following will cause application crashthere are three options
ANS. char * p = new char;
Char *q=p;
Delete p;
Delete q;
Q11 for typeid to give correct result which condition is must
Ans. Class should be polymorphic
Q12 following things are default when class is created
Ans. Default constructor, copy constructor, assignment operator
Q13. which casting is done at run time
Ans. dynamic_cast
Ans. stack is cleaned by the callee
Q2. mutable key word is used for
Ans. if used with a member variable it can be changes by a function declared as a constant
Q3. foo & const ref
Ans. this is not a good practise since references are always constants
Q4. private inheritance means
Ans Non private members of a base class become private members of derived class
Q5. int I=2;
Int j=3;
Int k=4;
Cout<<(I < j < k)
Ans. 1
Q6 #defines macro(a) ((a++) + (++a) + (a++))
Main()
{
cout << macro(1);
}
Ans. 4
Q7 string s = abcd
Char &c=s[1];
String t;
T=s;
c=z;
if(T[1]==z)
{
cout<
else
{
cout<
Ans. express
Q8. int func(int I)
{
static int k=0;
k++;
if( K>5)
return 1;
else
return func(I-1);
}
int main()
{
cout << func(1);
}
Ans. 1
Q9. class base
{
public:
virtual func()
{
cout <
};
class der1: public base
{
public:
virtual func()
{
cout << DER1;
}
};
class der2: public base
{
public:
virtual func()
{
cout << DER2;
}
};
class der3: public base
{
public:
virtual func1()
{
cout << DER3;
}
};
main()
{
base *pb;
pb= new der1;
pb->func();
pb= new der2;
pb->func();
pb= new der3;
pb->func();
}
Ans: DER1DER2BASE
Q10 Which of following will cause application crashthere are three options
ANS. char * p = new char;
Char *q=p;
Delete p;
Delete q;
Q11 for typeid to give correct result which condition is must
Ans. Class should be polymorphic
Q12 following things are default when class is created
Ans. Default constructor, copy constructor, assignment operator
Q13. which casting is done at run time
Ans. dynamic_cast
Labels:
Quark
QUARK Placement
QUARK Placement Sample Question Paper
C - Question Paper
Note : There are 20 questions and no negative marking.
Time allotted is 30 minutes
1. What is the output of the following code
main()
{
printf("Hello %d",printf("QUARK test? "));
}
a. Compile time error.
b. Hello QUARK test?
c. Run time error.
d. None of the above.
e. Quark Test ?Hello.
Ans. d.
This is because the evaluation of the parameters in a function call is done from right to left, becz the parameters were passed via a stack hence the first parameter (the leftmost one) is at the bottom of the stack and the rightmost parameter (if it is an expresseion, it will be evaluated before putting it on the stack) is on the top of the stack, hence while popping the parameters from the stack, the function printf (or any other function) gets them in the reverse order, i.e., from right to left, hence the statement printf("Quark test? ") gets evaluated first while pushing it as a parameter on to the stack, and then the statement printf("Hello %d") is executed. The '12' is the result of the return of printf("Quark test? ") which returns the number of characters printed.
2.) Out put of the following code is
main()
{
int i,j,A;
for (A = -1;A<=1; A++)
printf("%d\t",!!A);
}
a. 1 0 1
b. 65534 0 65534
c. -1 0 1
d. -65534 0 65534
e. None of the above
Ans. 1 0 1
3) What is the out put of the following code?
main()
{
int i=255;
printf("%d\t",++(i++));
}
a. Compilation error
b. Runtime error
c. 256
d. 0
e. None of the above
Ans. Compile Time Error 'Lvalue Required
4) What shall be the output of the following code?
main()
{
char i = 'a';
printf("%c \t %c \t", i ,(++i));
}
a. a b
b. Compile time error
c. b b
d. a a
e. 65 66
Ans. b b
5) What shall be the output of the following code?
main() {
int i,j;
printf("QUARK %s\n",main());
}
a. Compilation error.
b. Run-time error
c. Continuous scrolling Quark on the screen.
d. None of the above.
Ans. There is nothing on the screen and prog waits till the memory lasts and then out of memory run time error, so ans is b.
6) What shall be the output of the following code ?
#define f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a. 8
b. 64
c. 10
d. 12
Ans. f(2+2) will expand to 2+2*2+2*2+2
= 2+4+4+2
= 12
7) What shall be the output of the following code ?
main()
{
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
fun1(temp);}
void fun1(void *temp1 )
{
int t1 = 0;
while(*((char*)temp1+ t1++ )!='\0') {
printf("%c",*((char*)temp1 + t1));
}
}
a. Compilation error
b. ark
c. quark
d. uark
Ans, uark
8. What will be the out put of the following code?
void main()
{ int x=3;
printf("%d\t %d",x>>1, x<<3);
}
a. 1 and 4
b. 1 and 24
c. 1 and 27
d. None of the above
Ans. 1 and 24
This is because 3 in binary is 00000000 00000011 in two bytes (integer). Again, the right to left evaluation rule of parameters is applicable and so x<<3 gets executed first, it means left shift 3 times, but this operator does not change the value of x itself, it simply returns a value, so x retains its value after this operation has been carried out, so we get 00000000 00011000 which is 24, so 24 is pushed onto the stack, and then x>>1, right shift 1, 00000000 00000011, which is 1 in decimal, so 1 is pushed onto the stack, then printf("%d\t %d") gets executed displaying 1 24.
9. What will be the result of the following code?
int *x;
x =(int *) 15;
a. Compilation error
b. Compiles but gives a runtime error
c. Absolute location 15 in the memory space shall be assigned to pointer x;
d. Location 15 in the program space is assigned to pointer x;
e. Location 15 contains the address to an integer.
Ans d
10. Which of the following functions cannot be called from another file?
a. const void func(){ ……..}
b. extern void func(){………}
c. void func(){………}
d. static void func(){……….}
Ans. static
11. What will be the out come of the following code?
#include
int * func(){
static int x=0;
x++; return &x;
}
int main()
{
int * y = func();
printf("%d",(*y)++);
func();
printf("%d\n",*y);
return 0;
}
a. Compilation error.
b. Prints 1 and 3
c. Prints 1 and 3 but it is not good practice.
d. Prints 1 and 1
e. The code will not execute properly because y points to a variable whose life span is limited to execution of the function func();
Ans. Prints 1 and 3 but it is not a good practice
12. Referring to the above code , which of the following would be the correct
implementation for myFunc ?
char *format = "%d";
int main()
{
int x;
myFunc(scanf,&x);
printf("%d\n",x);
return(0);
}
a. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,&x);}
b. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,*x);}
c. void myFunc(int*y(const char*,…),int *x) {(*y)(format,&x);}
d. void myFunc(*(int y(const char*,…)),int *x) {(*y)(format,x);}
e. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,x);}
C - Question Paper
Note : There are 20 questions and no negative marking.
Time allotted is 30 minutes
1. What is the output of the following code
main()
{
printf("Hello %d",printf("QUARK test? "));
}
a. Compile time error.
b. Hello QUARK test?
c. Run time error.
d. None of the above.
e. Quark Test ?Hello.
Ans. d.
This is because the evaluation of the parameters in a function call is done from right to left, becz the parameters were passed via a stack hence the first parameter (the leftmost one) is at the bottom of the stack and the rightmost parameter (if it is an expresseion, it will be evaluated before putting it on the stack) is on the top of the stack, hence while popping the parameters from the stack, the function printf (or any other function) gets them in the reverse order, i.e., from right to left, hence the statement printf("Quark test? ") gets evaluated first while pushing it as a parameter on to the stack, and then the statement printf("Hello %d") is executed. The '12' is the result of the return of printf("Quark test? ") which returns the number of characters printed.
2.) Out put of the following code is
main()
{
int i,j,A;
for (A = -1;A<=1; A++)
printf("%d\t",!!A);
}
a. 1 0 1
b. 65534 0 65534
c. -1 0 1
d. -65534 0 65534
e. None of the above
Ans. 1 0 1
3) What is the out put of the following code?
main()
{
int i=255;
printf("%d\t",++(i++));
}
a. Compilation error
b. Runtime error
c. 256
d. 0
e. None of the above
Ans. Compile Time Error 'Lvalue Required
4) What shall be the output of the following code?
main()
{
char i = 'a';
printf("%c \t %c \t", i ,(++i));
}
a. a b
b. Compile time error
c. b b
d. a a
e. 65 66
Ans. b b
5) What shall be the output of the following code?
main() {
int i,j;
printf("QUARK %s\n",main());
}
a. Compilation error.
b. Run-time error
c. Continuous scrolling Quark on the screen.
d. None of the above.
Ans. There is nothing on the screen and prog waits till the memory lasts and then out of memory run time error, so ans is b.
6) What shall be the output of the following code ?
#define f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a. 8
b. 64
c. 10
d. 12
Ans. f(2+2) will expand to 2+2*2+2*2+2
= 2+4+4+2
= 12
7) What shall be the output of the following code ?
main()
{
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
fun1(temp);}
void fun1(void *temp1 )
{
int t1 = 0;
while(*((char*)temp1+ t1++ )!='\0') {
printf("%c",*((char*)temp1 + t1));
}
}
a. Compilation error
b. ark
c. quark
d. uark
Ans, uark
8. What will be the out put of the following code?
void main()
{ int x=3;
printf("%d\t %d",x>>1, x<<3);
}
a. 1 and 4
b. 1 and 24
c. 1 and 27
d. None of the above
Ans. 1 and 24
This is because 3 in binary is 00000000 00000011 in two bytes (integer). Again, the right to left evaluation rule of parameters is applicable and so x<<3 gets executed first, it means left shift 3 times, but this operator does not change the value of x itself, it simply returns a value, so x retains its value after this operation has been carried out, so we get 00000000 00011000 which is 24, so 24 is pushed onto the stack, and then x>>1, right shift 1, 00000000 00000011, which is 1 in decimal, so 1 is pushed onto the stack, then printf("%d\t %d") gets executed displaying 1 24.
9. What will be the result of the following code?
int *x;
x =(int *) 15;
a. Compilation error
b. Compiles but gives a runtime error
c. Absolute location 15 in the memory space shall be assigned to pointer x;
d. Location 15 in the program space is assigned to pointer x;
e. Location 15 contains the address to an integer.
Ans d
10. Which of the following functions cannot be called from another file?
a. const void func(){ ……..}
b. extern void func(){………}
c. void func(){………}
d. static void func(){……….}
Ans. static
11. What will be the out come of the following code?
#include
int * func(){
static int x=0;
x++; return &x;
}
int main()
{
int * y = func();
printf("%d",(*y)++);
func();
printf("%d\n",*y);
return 0;
}
a. Compilation error.
b. Prints 1 and 3
c. Prints 1 and 3 but it is not good practice.
d. Prints 1 and 1
e. The code will not execute properly because y points to a variable whose life span is limited to execution of the function func();
Ans. Prints 1 and 3 but it is not a good practice
12. Referring to the above code , which of the following would be the correct
implementation for myFunc ?
char *format = "%d";
int main()
{
int x;
myFunc(scanf,&x);
printf("%d\n",x);
return(0);
}
a. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,&x);}
b. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,*x);}
c. void myFunc(int*y(const char*,…),int *x) {(*y)(format,&x);}
d. void myFunc(*(int y(const char*,…)),int *x) {(*y)(format,x);}
e. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,x);}
Labels:
Quark
QUARK Placement
QUARK Placement Sample Question Paper
C - Question Paper
Note : There are 20 questions and no negative marking.
Time allotted is 30 minutes
1. What is the output of the following code
main()
{
printf("Hello %d",printf("QUARK test? "));
}
a. Compile time error.
b. Hello QUARK test?
c. Run time error.
d. None of the above.
e. Quark Test ?Hello.
Ans. d.
This is because the evaluation of the parameters in a function call is done from right to left, becz the parameters were passed via a stack hence the first parameter (the leftmost one) is at the bottom of the stack and the rightmost parameter (if it is an expresseion, it will be evaluated before putting it on the stack) is on the top of the stack, hence while popping the parameters from the stack, the function printf (or any other function) gets them in the reverse order, i.e., from right to left, hence the statement printf("Quark test? ") gets evaluated first while pushing it as a parameter on to the stack, and then the statement printf("Hello %d") is executed. The '12' is the result of the return of printf("Quark test? ") which returns the number of characters printed.
2.) Out put of the following code is
main()
{
int i,j,A;
for (A = -1;A<=1; A++)
printf("%d\t",!!A);
}
a. 1 0 1
b. 65534 0 65534
c. -1 0 1
d. -65534 0 65534
e. None of the above
Ans. 1 0 1
3) What is the out put of the following code?
main()
{
int i=255;
printf("%d\t",++(i++));
}
a. Compilation error
b. Runtime error
c. 256
d. 0
e. None of the above
Ans. Compile Time Error 'Lvalue Required
4) What shall be the output of the following code?
main()
{
char i = 'a';
printf("%c \t %c \t", i ,(++i));
}
a. a b
b. Compile time error
c. b b
d. a a
e. 65 66
Ans. b b
5) What shall be the output of the following code?
main() {
int i,j;
printf("QUARK %s\n",main());
}
a. Compilation error.
b. Run-time error
c. Continuous scrolling Quark on the screen.
d. None of the above.
Ans. There is nothing on the screen and prog waits till the memory lasts and then out of memory run time error, so ans is b.
6) What shall be the output of the following code ?
#define f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a. 8
b. 64
c. 10
d. 12
Ans. f(2+2) will expand to 2+2*2+2*2+2
= 2+4+4+2
= 12
7) What shall be the output of the following code ?
main()
{
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
fun1(temp);}
void fun1(void *temp1 )
{
int t1 = 0;
while(*((char*)temp1+ t1++ )!='\0') {
printf("%c",*((char*)temp1 + t1));
}
}
a. Compilation error
b. ark
c. quark
d. uark
Ans, uark
8. What will be the out put of the following code?
void main()
{ int x=3;
printf("%d\t %d",x>>1, x<<3);
}
a. 1 and 4
b. 1 and 24
c. 1 and 27
d. None of the above
Ans. 1 and 24
This is because 3 in binary is 00000000 00000011 in two bytes (integer). Again, the right to left evaluation rule of parameters is applicable and so x<<3 gets executed first, it means left shift 3 times, but this operator does not change the value of x itself, it simply returns a value, so x retains its value after this operation has been carried out, so we get 00000000 00011000 which is 24, so 24 is pushed onto the stack, and then x>>1, right shift 1, 00000000 00000011, which is 1 in decimal, so 1 is pushed onto the stack, then printf("%d\t %d") gets executed displaying 1 24.
9. What will be the result of the following code?
int *x;
x =(int *) 15;
a. Compilation error
b. Compiles but gives a runtime error
c. Absolute location 15 in the memory space shall be assigned to pointer x;
d. Location 15 in the program space is assigned to pointer x;
e. Location 15 contains the address to an integer.
Ans d
10. Which of the following functions cannot be called from another file?
a. const void func(){ ……..}
b. extern void func(){………}
c. void func(){………}
d. static void func(){……….}
Ans. static
11. What will be the out come of the following code?
#include
int * func(){
static int x=0;
x++; return &x;
}
int main()
{
int * y = func();
printf("%d",(*y)++);
func();
printf("%d\n",*y);
return 0;
}
a. Compilation error.
b. Prints 1 and 3
c. Prints 1 and 3 but it is not good practice.
d. Prints 1 and 1
e. The code will not execute properly because y points to a variable whose life span is limited to execution of the function func();
Ans. Prints 1 and 3 but it is not a good practice
12. Referring to the above code , which of the following would be the correct
implementation for myFunc ?
char *format = "%d";
int main()
{
int x;
myFunc(scanf,&x);
printf("%d\n",x);
return(0);
}
a. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,&x);}
b. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,*x);}
c. void myFunc(int*y(const char*,…),int *x) {(*y)(format,&x);}
d. void myFunc(*(int y(const char*,…)),int *x) {(*y)(format,x);}
e. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,x);}
C - Question Paper
Note : There are 20 questions and no negative marking.
Time allotted is 30 minutes
1. What is the output of the following code
main()
{
printf("Hello %d",printf("QUARK test? "));
}
a. Compile time error.
b. Hello QUARK test?
c. Run time error.
d. None of the above.
e. Quark Test ?Hello.
Ans. d.
This is because the evaluation of the parameters in a function call is done from right to left, becz the parameters were passed via a stack hence the first parameter (the leftmost one) is at the bottom of the stack and the rightmost parameter (if it is an expresseion, it will be evaluated before putting it on the stack) is on the top of the stack, hence while popping the parameters from the stack, the function printf (or any other function) gets them in the reverse order, i.e., from right to left, hence the statement printf("Quark test? ") gets evaluated first while pushing it as a parameter on to the stack, and then the statement printf("Hello %d") is executed. The '12' is the result of the return of printf("Quark test? ") which returns the number of characters printed.
2.) Out put of the following code is
main()
{
int i,j,A;
for (A = -1;A<=1; A++)
printf("%d\t",!!A);
}
a. 1 0 1
b. 65534 0 65534
c. -1 0 1
d. -65534 0 65534
e. None of the above
Ans. 1 0 1
3) What is the out put of the following code?
main()
{
int i=255;
printf("%d\t",++(i++));
}
a. Compilation error
b. Runtime error
c. 256
d. 0
e. None of the above
Ans. Compile Time Error 'Lvalue Required
4) What shall be the output of the following code?
main()
{
char i = 'a';
printf("%c \t %c \t", i ,(++i));
}
a. a b
b. Compile time error
c. b b
d. a a
e. 65 66
Ans. b b
5) What shall be the output of the following code?
main() {
int i,j;
printf("QUARK %s\n",main());
}
a. Compilation error.
b. Run-time error
c. Continuous scrolling Quark on the screen.
d. None of the above.
Ans. There is nothing on the screen and prog waits till the memory lasts and then out of memory run time error, so ans is b.
6) What shall be the output of the following code ?
#define f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a. 8
b. 64
c. 10
d. 12
Ans. f(2+2) will expand to 2+2*2+2*2+2
= 2+4+4+2
= 12
7) What shall be the output of the following code ?
main()
{
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
fun1(temp);}
void fun1(void *temp1 )
{
int t1 = 0;
while(*((char*)temp1+ t1++ )!='\0') {
printf("%c",*((char*)temp1 + t1));
}
}
a. Compilation error
b. ark
c. quark
d. uark
Ans, uark
8. What will be the out put of the following code?
void main()
{ int x=3;
printf("%d\t %d",x>>1, x<<3);
}
a. 1 and 4
b. 1 and 24
c. 1 and 27
d. None of the above
Ans. 1 and 24
This is because 3 in binary is 00000000 00000011 in two bytes (integer). Again, the right to left evaluation rule of parameters is applicable and so x<<3 gets executed first, it means left shift 3 times, but this operator does not change the value of x itself, it simply returns a value, so x retains its value after this operation has been carried out, so we get 00000000 00011000 which is 24, so 24 is pushed onto the stack, and then x>>1, right shift 1, 00000000 00000011, which is 1 in decimal, so 1 is pushed onto the stack, then printf("%d\t %d") gets executed displaying 1 24.
9. What will be the result of the following code?
int *x;
x =(int *) 15;
a. Compilation error
b. Compiles but gives a runtime error
c. Absolute location 15 in the memory space shall be assigned to pointer x;
d. Location 15 in the program space is assigned to pointer x;
e. Location 15 contains the address to an integer.
Ans d
10. Which of the following functions cannot be called from another file?
a. const void func(){ ……..}
b. extern void func(){………}
c. void func(){………}
d. static void func(){……….}
Ans. static
11. What will be the out come of the following code?
#include
int * func(){
static int x=0;
x++; return &x;
}
int main()
{
int * y = func();
printf("%d",(*y)++);
func();
printf("%d\n",*y);
return 0;
}
a. Compilation error.
b. Prints 1 and 3
c. Prints 1 and 3 but it is not good practice.
d. Prints 1 and 1
e. The code will not execute properly because y points to a variable whose life span is limited to execution of the function func();
Ans. Prints 1 and 3 but it is not a good practice
12. Referring to the above code , which of the following would be the correct
implementation for myFunc ?
char *format = "%d";
int main()
{
int x;
myFunc(scanf,&x);
printf("%d\n",x);
return(0);
}
a. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,&x);}
b. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,*x);}
c. void myFunc(int*y(const char*,…),int *x) {(*y)(format,&x);}
d. void myFunc(*(int y(const char*,…)),int *x) {(*y)(format,x);}
e. void myFunc(int(*y)(const char*,…),int *x) {(*y)(format,x);}
Labels:
Quark
New MicrosoftWord
13. What shall be the output of the following C code?
void main()
{
unsigned int x= -1;
int y =0;
if(y<=x) printf("A is true\n");
if (y = =(x = -10)) printf("B is true\n");
if ((int) x>=y) printf("C is true\n");
}
a. A is true.
b. B is true.
c. C is true.
d. None of the above.
Ans. A is true because x contains -1, i.e., in binary it is ffff, i.e., all 1s, so being unsigned, all 1s are interpreted as the value 65535 and not as -1 (however, all 1s are interpreted as -1 if it is just an int), hence y<=x returns true.
14. In the following code what is the correct way to increment the variable ptr to
point to the next member of the array
union intfloat
{
int intArray[ 5];
float floatArray[ 5];
};
union intfloat arr[20];
void *ptr =arr;
a. ++(int*)ptr;
b. ptr = ptr+5;
c. ptr = ptr +sizeof(*ptr);
d. ptr = ptr+sizeof(intfloat.floatArray);
e. ptr = (void*)((union intfloat*)ptr +1);
Ans. e. ptr = (void*)((union intfloat*)ptr +1);
15.What shall be the output of the following program?
#define PRINTXYZ(x,y,z) printf (#x "=%d\t" #z "=%d\n", x, y)
void main() {
int x, y, z;
x=0; y=1; z=2;
x || ++y ||++z;
PRINTXYZ(x,y,z);
++x || ++y && ++z;
PRINTXYZ(x,y,z);
++x && ++y || ++z;
PRINTXYZ(x,y,z);
}
a. Compilation error.
b. Runtime error.
c.
x=0 z=2
x=1 z=3
x=2 z=4
d.
x=0 z=2
x=1 z=2
x=2 z=3
e. None of the above.
Ans. d.
16. What shall be the output of the following code ?
main()
{
printf("%d %d", sizeof(NULL), sizeof(""));
}
a. 1 and 0.
b. 0 and 1
c. 2 and 1
d. 4 and 1
e. None of the above
Ans. Depends on the machine and compiler. Actually it is the sizeof(int) and sizeof(char) as a string is stored as a char array terminated with 0, so sizeof("") gives 1, whereas sizeof("adsf") gives 5 (including the terminating 0). So in TurboC we get c as the answer, on VC we get d as the answer, so I guess e is the ans, i.e., None of the above.
17. What shall be the output of the following code?
int *check ( int,int);
void main()
{int c,d;
c = check(11,29);
d= check(20,30);
printf("\nc=%u",c);
}
int * check(int i,int j )
{
int *p, *q;
p=&i;
q=&j;
if(i>=95)
return(q);
else
return(p);
}
a. 11
b. 29
c. Compilation error
d. Runtime error
e. None of the above.
Ans. e. None of the above. the statement c = check(11,29) is assigning an int ptr to an int, so c has an address of an int (which has gone out of scope, since the function returns the address of a variable which had its scope only inside the function, since the parameters were passed by value) so the value printed can be anything. Instead, if the statement was c = *(check(11,29)) then c would have the value stored at the address returned by the function, which would most probably be 11, but it cannot be guaranteed since the variable i has fallen out of scope.
18. What shall be the output of the following code?
void main()
{int a[3][2]={ 1,2,
5,7,
6,8};
printf("\n%d",((a+1)-(&a+1)));
}
a. 0
b. -16
c. -2
d. -8
e. None of the above.
Ans. -2. I haven't been able to figure this one out. a is the address of the 2-d array, here a, &a, *a all give the same value, i.e., address of the array. (a+1) gives the address of the second row, it is the same as a[1]. *(a+1) gives the address of the first cell of the second row. **(a+1) gives the value of the element stored in the first cell in the second row. (*(a+1)+1) gives the address of the second cell of the second row. *(*(a+1)+1) gives the value of the element stored in the second cell in the second row.
19.What shall be the output of the following code?
main()
{
char str1[]="Hello";
char str2[]="Hello";
if(str1= =str2&& (*(str1+6)= =*(str2+6)))
printf("\n Equal");
else
printf("\n unequal");
}
a. Equal
b. Unequal
c. Compilation error.
d. Runtime error.
e. None of the above.
Ans. b. Unequal, because the addresses of the two strings are str1 and str2 and they are different.
20. Given that sizeof(int) is 2 , what is the output of the following code
main()
{
int a, b=255,c=127;
a=~b;
c=c^(~a & b|0);\
c=c^(~(~b));
printf("%d\n",c);
}
a. Error because of overflow;
b. 255
c. -256
d. 127
e. None of the above
Ans. d. 127
void main()
{
unsigned int x= -1;
int y =0;
if(y<=x) printf("A is true\n");
if (y = =(x = -10)) printf("B is true\n");
if ((int) x>=y) printf("C is true\n");
}
a. A is true.
b. B is true.
c. C is true.
d. None of the above.
Ans. A is true because x contains -1, i.e., in binary it is ffff, i.e., all 1s, so being unsigned, all 1s are interpreted as the value 65535 and not as -1 (however, all 1s are interpreted as -1 if it is just an int), hence y<=x returns true.
14. In the following code what is the correct way to increment the variable ptr to
point to the next member of the array
union intfloat
{
int intArray[ 5];
float floatArray[ 5];
};
union intfloat arr[20];
void *ptr =arr;
a. ++(int*)ptr;
b. ptr = ptr+5;
c. ptr = ptr +sizeof(*ptr);
d. ptr = ptr+sizeof(intfloat.floatArray);
e. ptr = (void*)((union intfloat*)ptr +1);
Ans. e. ptr = (void*)((union intfloat*)ptr +1);
15.What shall be the output of the following program?
#define PRINTXYZ(x,y,z) printf (#x "=%d\t" #z "=%d\n", x, y)
void main() {
int x, y, z;
x=0; y=1; z=2;
x || ++y ||++z;
PRINTXYZ(x,y,z);
++x || ++y && ++z;
PRINTXYZ(x,y,z);
++x && ++y || ++z;
PRINTXYZ(x,y,z);
}
a. Compilation error.
b. Runtime error.
c.
x=0 z=2
x=1 z=3
x=2 z=4
d.
x=0 z=2
x=1 z=2
x=2 z=3
e. None of the above.
Ans. d.
16. What shall be the output of the following code ?
main()
{
printf("%d %d", sizeof(NULL), sizeof(""));
}
a. 1 and 0.
b. 0 and 1
c. 2 and 1
d. 4 and 1
e. None of the above
Ans. Depends on the machine and compiler. Actually it is the sizeof(int) and sizeof(char) as a string is stored as a char array terminated with 0, so sizeof("") gives 1, whereas sizeof("adsf") gives 5 (including the terminating 0). So in TurboC we get c as the answer, on VC we get d as the answer, so I guess e is the ans, i.e., None of the above.
17. What shall be the output of the following code?
int *check ( int,int);
void main()
{int c,d;
c = check(11,29);
d= check(20,30);
printf("\nc=%u",c);
}
int * check(int i,int j )
{
int *p, *q;
p=&i;
q=&j;
if(i>=95)
return(q);
else
return(p);
}
a. 11
b. 29
c. Compilation error
d. Runtime error
e. None of the above.
Ans. e. None of the above. the statement c = check(11,29) is assigning an int ptr to an int, so c has an address of an int (which has gone out of scope, since the function returns the address of a variable which had its scope only inside the function, since the parameters were passed by value) so the value printed can be anything. Instead, if the statement was c = *(check(11,29)) then c would have the value stored at the address returned by the function, which would most probably be 11, but it cannot be guaranteed since the variable i has fallen out of scope.
18. What shall be the output of the following code?
void main()
{int a[3][2]={ 1,2,
5,7,
6,8};
printf("\n%d",((a+1)-(&a+1)));
}
a. 0
b. -16
c. -2
d. -8
e. None of the above.
Ans. -2. I haven't been able to figure this one out. a is the address of the 2-d array, here a, &a, *a all give the same value, i.e., address of the array. (a+1) gives the address of the second row, it is the same as a[1]. *(a+1) gives the address of the first cell of the second row. **(a+1) gives the value of the element stored in the first cell in the second row. (*(a+1)+1) gives the address of the second cell of the second row. *(*(a+1)+1) gives the value of the element stored in the second cell in the second row.
19.What shall be the output of the following code?
main()
{
char str1[]="Hello";
char str2[]="Hello";
if(str1= =str2&& (*(str1+6)= =*(str2+6)))
printf("\n Equal");
else
printf("\n unequal");
}
a. Equal
b. Unequal
c. Compilation error.
d. Runtime error.
e. None of the above.
Ans. b. Unequal, because the addresses of the two strings are str1 and str2 and they are different.
20. Given that sizeof(int) is 2 , what is the output of the following code
main()
{
int a, b=255,c=127;
a=~b;
c=c^(~a & b|0);\
c=c^(~(~b));
printf("%d\n",c);
}
a. Error because of overflow;
b. 255
c. -256
d. 127
e. None of the above
Ans. d. 127
Labels:
Quark
Subscribe to:
Posts (Atom)