Sunday, May 18, 2008

HCL aptitude paper HYD 2007 NOV

1. S 1=={1,2,3,4}, S 2 =={A,B.C……….Z},S 3=={……………},(S1*S2)U S3==?
2. 8*7=B,how much is 6*9== ?
3. 4 to 5 questions on simplifying complex nos. equations
4. Sphere of radius 4.5 cm is divide in three spheres ,two have radius 1.5 and 2 cm,find the other ones??
5. If COMPLEX == 81,and……how much is ANALYSE==?? 2-3 questions based on similar pattern
6. Two taps a and b fill up a cistern in 2 and3 hrs ,at wat time should b be clsed if the tank cistern is filled up in 17 minutes??
7. A doctor checks 5 patients every 3 hrs with abreak of 10 minutes between each two check many he patients he checks in 10 hrs and 15 minutes??
8. no. of diagonals friends if vertices of a octagon are joined??
9. An equilateral triangle is formed by joining the centers of sides of a equilateral triangle.wat is the ratio of area ,s of both the triangles??
10. A can finish the work in 3 days , B can finish the work in double efficiency, can finish with equal efficiency of both A and B.if all work together within how many days will they complete the work?

Oracle job Placement paper

Three beauty pageant finalists-Cindy, Amy and Linda-The winner was musician. The one who was not last or first was a math major. The one who came in third had black hair. Linda had red hair. Amy had no musical abilities. Who was first?
(A) Cindy (B) Amy (C) Linda (D) None of these

2. Two twins have certain peculiar characteristics. One of them always lies on Monday, Wednesday, Friday. The other always lies on Tuesdays, Thursday and Saturdays. On the other days they tell the truth. You are given a conversation.
Person A- today is Sunday, my name is Anil
Person B-today is Tuesday, my name is Bill What day is today?
(A) Sunday (B) Tuesday (C) Monday (D) Thursday

3. The difference of a number and its reciprocal is 1/2.The sum of their squares is
(A) 9/4 (B) 4/5 (C) 5/3 (D) 7/4

4. The difference of a number and its square is 870.What is the number?
(A) 42 (B) 29 (C) 30 (D) 32

5. A trader has 100 Kg of wheat, part of which he sells at 5% profit and the rest at 20% profit. He gains 15% on the whole. Find how much is sold at 5% profit?
(A) 60 (B) 50 (C) 66.66 (D) 33.3

6. Which of the following points are collinear?
(A) (3,5) (4,6) (2,7) (B) (3,5) (4,7) (2,3)
(C) (4,5) (4,6) (2,7) (D) (6,7) (7,8) (2,7)

7. A man leaves office daily at 7pm.a driver with car comes from his home to pick him from office and bring back home. One day he gets free at 5.30 and instead of waiting for driver he starts walking towards home. In the way he meets the car and returns home on car. He reaches home 20 minutes earlier than usual. In how much time does the man reach home usually?
(A) 1 hr 20 min (B) 1 hr (C) 1 hr 10 min (D) 55 min

. If m:n = 2:3,the value of 3m+5n/6m-n is
(A) 7/3 (B) 3/7 (C) 5/3 (D) 3/5

9. A dog taken four leaps for every five leaps of hare but three leaps of the dog is equal to four leaps of the hare. Compare speed?
(A) 12:16 (B) 19:20 (C) 16:15 (D) 10:12

10. A watch ticks 90 times in 95 seconds. And another watch ticks 315 times in 323 secs. If they start together, how many times will they tick together in first hour?
(A) 100 times (B) 101 times (C) 99 times (D) 102 times

11. The purpose of defining an index is
(A) Enhance Sorting Performance (B) Enhance
Searching Performance
(C) Achieve Normalization (D) All of the above

12. A transaction does not necessarily need to be
(A) Consistent (B) Repeatable (C) Atomic (D) Isolated

13. To group users based on common access permission one should use
(A) User Groups (B) Roles (C) Grants (D) None of the above

14. PL/SQL uses which of the following
(A) No Binding (B) Early Binding (C) Late Binding (D) Deferred Binding

15. Which of the constraint can be defined at the table level as well as at the column level
(A) Unique (B) Not Null (C) Check (D) All the above

Oracle- Placement -Paper Latest

December 31, 2007

Oracle Latest Fresher Placement Sample Question Question Paper 3

Oracle Paper

The test was of 1 hour 30 ques. g apti and 30 of
ques. of g apti were very lengthy so don't end up in solving
them…..time was less……some 15 ques. from arithmetic……and

ORACLE Latest Fresher Engineer Placement Sample Question Paper 3

logical,statement interpretation,arrangement,tense
i am enclosing here the 2 C questions :
1. given a square matrix which consists only of 1 and 0……find
rows,which cols and which diagonals consist entirely of 1's.
2. given an array of integers find all possible combinations of
numbers whose sum equal to 90…..
ans : knapsack problem (in data structures - aho ullman)
Note : for them solution was not the criteria…….but the
was important……the solution should be generalised and
optimized……..optimization was given the top priority……..
here is the techincal paper :
plz try to solve them urself by trying on comp.
1. const int MAX=10;
{enum a {a,b,MAX};
print MAX;
2. enum object is a const which can only be assigned a value at
initialization or a variable which can be assigned any value in
middle of
the program?
3. void *p;
what operation cannot be performed on p?
ans : arithmetic operation unless it is properly typecasted
4. char **p="Hello";
print p,*p,**p
5. main()
{char str[]="Geneius";
print (str);
print(char *s)
6. what does the function fcloseall() does ?
7. main()
{printf("Genius %d",fun(123));
fun(int n)
{return (printf("%d",n));
8. difference between definition and declaration.
9. find the error?
{int i=10;
b=300; c=2–; printf("\n%d%d",b,c);}
4) Identify the error in
{char c1='a',c2='Z';
if (c1=='a'or c2=='z') printf("welcome");}
5) What will the following program print
{inti; for(i=0;i
4) How would you declare a PL/SQL table of records to
holdthe rows selectd from the EMP table ?
5) Which statement about Implicit cursor is true ?
a) Implicit cursors are declared implicitly only from
b) Implicit cursors are dclared implicitly for all the
DML and SELECT statements
c) Programmers needs to close all implicit cursors
before the end of PL/SQL programs
d) Programmers can declare Implicit cursors by using
cursor type in declaraion section
6) Evaluate this PL/SQL Block
V_Result number(2)
WHERE department id (20,30,80);
What will be the value of v_result if no rows are
a) 0 b) 1 c) TRUE d) NULL
7) Which two conditions in a PL/SQL block cause an
exception error to occur ? ( Choose 2 )
a) Select statement does not return a row
b) select stmt returns more than one row
c) select statement contaains a group by clause
d) seelct statenent donot have where clause
e) data type in the select list are inconsistent whith
data types in the into clause

Quark Latest Placement Papers Freshers

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, 01 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 A's income is 25% less than B's ,by what % is B's 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 *** 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

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

Quark Latest ANALYTICAL Placement Papers

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?

A) Mr.Ram Only
B) Mr.Sham Only.
C) Either Mr.Ram or Mr.Sham
D) 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?
A) Mr. Sham and Mr.Lalu.
B) Mr. Ram and Mr. Sham
C) Mr. Ram and Mr. Raju
D) 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

Ans. B

17) Of the languages spoken the most common languages are
A) English and Tamil
B) English and Hindi
C) English and Telugu
D) Hindi and Tamil

Ans. D

Directions for Questions Nos:18 to 21
Four people of different nationalities live on the same side of a street in four houses each of different color. Each person has a different favorite drink. The following additional information also known:
The Englishman lives in the red house.
The Italian drinks tea.
The Norwegian lives in the first house on the left.
In the second house from the right they drink milk
The Norwegian lives adjacent to the blue house
The Spaniard drinks fruit juice
Tea is drunk in the blue house.
The White House is to the right of the red house

18) Milk is drunk by
A) Norwegian
B) Englishman
C) Italian
D) None of these

Ans. B

19) The Norwegian drinks
A) Milk
B) Cocoa
C) Tea
D) Fruit Juice

Ans. B

20) The color of Norwegian's house is
A) Yellow
B) White
C) Blue
D) Red

Ans. A

21) Which of the following is not true:
A) Milk is drunk in the red house
B) Italian lives in the blue house
C) The Spaniard lives in a corner house
D) The Italian lives next to Spaniard.

Ans. D

Directions for Questions Nos: 22 to 23
Kya-Kya is an island in the south pacific .The inhabitants of Kya-Kya always answer any question with two sentences, one of which is always true and other is always false.

22) You are walking on a road and come to a fork. You ask the inhabitants Ram, Laxman, Lila,"Which road will take me to the village?"
Ram says,"I never speak to strangers. I am new to this place"
Laxman says,"I am married to Lila. Take the left road".
Lila says,"I am married to ram. He is not new to this place"
Which of the following is true?
A) Left road takes you to the village
B) Right road takes you to the village
C) Lila is married to laxman
D) None of above

Ans. A.
Ram said he never talked to strangers, but he spoke to a stranger, this means that this statement is false, hence his other statement must be true, hence the second statement of Lila is false, hence her first statement is true that is she is married to ram, hence the first statement of Laxman is false, hence his second statement is true, that is take the left road.

23) You find that your boat is stolen.You question three inhabitants of the island and they reply as follows:
John says,"I didn't do it. Mathew didn't do it"
Matthew says,"I didn't do it. Krishna didn't do it."
Krishna says,"I didn't do it .I don't know who did it."

Who stole your boat?
A) John
B) Matthew
C) Krishna
D) None of them.

Ans. B
Matthew said he didn't know who did it, but he also said he didn't do it, which means he knows who did it, which means his second statement is false, which means his first statement is true…

Directions for question nos 24-25: There are five trains A, B, C, D and E that run between the following stations:
Bombay and Pune
Calcutta and Bombay
Pune and Goa
Goa and Bombay
Pune and Calcutta

Trains A and D do not go to Bombay, B&C do not go to Calcutta and C & D do not touch Goa.

24) Train E goes from………… to………… and vice-versa

A.Pune and Calcutta
B.Bombay to Goa
C.Bombay to Calcutta
D.Goa to Pune.

Ans. C

25) Which train runs between Calcutta and Pune?
A) A
B) B
C) C
D) D

Ans. D

C++ Questions QUARK

1. What does the following do:

void afunction(int *x)
x=new int;
int main()
int v=10;
a) Outputs 12
b) Outputs 10
c) Outputs the address of v

Ans b.

2. How long does this loop run: for(int x=0; x=3; x++)
a) Never
b) Three times
c) Forever

Ans. c

3. Which uses less memory?
struct astruct
int x;
float y;
int v;

union aunion
int x;
float v;

char array[10];

Ans. b

4. Evaluate:
int fn(int v)
if(v==1 || v==0)
return 1;
return fn(v/2)+2;
return fn(v-1)+3;
for fn(7);

a) 10
b) 11
c) 1

Ans. b

5. Which of the Standard C++ casts can be used to perform a "safe" downcast:
a) reinterpret_cast
b) dynamic_cast
c) static_cast
d) const_cast

Ans. b

class professor {};
class teacher : public virtual professor {};
class researcher : public virtual professor {};
class myprofessor : public teacher, public researcher {};

Referring to the sample code above, if an object of class "myprofessor" were created, how many instances of professor will it contain?
a) 0
b) 1
c) 2
d) 3
e) 4

Ans. b , here professor will be called a virtual base class since teacher and researcher derive from it virtually. This is used in multiple inheritance as shown here. If professor was not inherited virtually then there would be 2 instances of professor in the object of myprofessor.

string somestring ;
Which of the following choices will convert a standard C++ string object "somestring" to a C string?
a) Copy.somestring () ;
b) somestring.c_str ()
c) &somestring [1]
d) std::cstring (somestring)
e) (char *) somestring

Ans. b

class ba***
int x;
void setx(int y) {x=y;}
class derived : ba*** {};
What is the access level for the member function "setx" in the class "derived" above?
a) private
b) local
c) global
d) public
e) protected

Ans. a

E) Table of Member Access Privileges
Access in Base Class Base Class Inherited as Access in Derived Class
Public Protected Private Public Public Protected No access1
Public Protected Private Protected Protected Protected No access1
Public Protected Private Private Private Private No access1
1 Unless friend declarations within the base class explicitly grant access.
So, the highest member accessibility is defined by the way a class is inherited, if it is inherited privately, then the highest member accessibility will be private. Default inheritance is private.

class Alpha {
char data[10000];
class Beta {
Beta() { n = 0; }
void FillData(Alpha a);

int n;
How do you make the above sample code more efficient?
a) If possible, make the constructor for Beta private to reduce the overhead of public constructors.
b) Change the return type in FillData to int to negate the implicit return conversion from "int" to "void".
c) Make the destructor for Alpha virtual.
d) Make the constructor for Alpha virtual.
e) Pass a const reference to Alpha in FillData

Ans. e. since u r passing a reference hence a new array will not be created in memory, whereas if u pass by value, then an array of 10000 chars will be created. Passing by reference only creates an alias for the original parameter (i.e., it points to the original parameter) and is same as passing by address, the only difference is that it can be used like an object instead of as a pointer, i.e., if param is &a, then u will write a.member, whereas if param is *a then u will write a->member.

class Foo {
int x;
Foo(int I);
If a class does not have a copy constructor explicitly defined one will be implicitly defined for it. Referring to the sample code above, which one of the following declarations is the implicitly created copy constructor?
a) Foo(Foo *f);
b) Foo(Foo &f);
c) Foo(const Foo *f);
d) Foo(const Foo &f);
e) Foo(int);

Ans. d. copy constructor takes an arg of its own type which is passed by ref and which should not be changed hence it is const

class HasStatic {
static int I;
Referring to the sample code above, what is the appropriate method of defining the member variable "I", and assigning it the value 10, outside of the class declaration?
a) HasStatic I = 10;
b) int static I = 10;
c) static I(10);
d) static I = 10;
e) int HasStatic::I = 10;

Ans. e

class X
int a;
X(){cout<<"X constructor was called"< ~X(){cout<<"X destructor was called"<};
Referring to the code above, which one of the following statements regarding "X" is TRUE?
a) X is an abstract class.
b) Only subclasses of X may create X objects.
c) Instances of X cannot be created.
d) X objects can only be created using the default copy constructor.
e) Only friends can create instances of X objects.

Ans. b. instances of X can be created only inside its subclasses.

class Foo {
const int x;
Foo(int f);
Foo f;
Referring to the sample code above, why will the class declaration not compile?
a) The variable x is const.
b) The destructor is protected.
c) The destructor is not public.
d) The constructor is protected.
e) There is no default constructor.

Ans. e. if u don't specify a constructor for a class, then the compiler generates the default constructor for u, but if u specify a constructor apart from the default constructor, then u must give the default constructor also, but only if u r creating an object which uses the default constructor. i.e., the following code is perfectly fine
class Foo {
Foo(int f){}
Foo f(0);

But if u try to create an object of Foo like this
Foo f;
then this will give compiler error because there is no default constructor available.

class Foo {
Foo(int i) { }
class Bar : virtual Foo {
Bar() { }

Bar b;

Referring to the above code, when the object 'b' is defined, a compiler error will occur. What action fixes the compiler error?
a) Adding a virtual destructor to the class Bar
b) Adding a constructor to Bar which takes an int parameter
c) Adding "Foo()" to the Bar constructor
d) Adding a copy constructor to the class Foo
e) Adding "Foo(0)" to the Bar::Bar initializer list

Ans. e

15. Which one of the following describes characteristics of "protected" inheritance?
a) The base class has access only to the public or protected members of the derived class.
b) The derived class has non-public, inheritable, access to all but the private members of the base class.
c) The derived class has access to all members of the base class.
d) The private members of the base class are visible within the derived class.
e) Public members of the derived class are privately accessible from the base class.

Ans. b

16. The "virtual" specifier in a member function enables which one of the following?
a) Monmorphism
b) Late binding
c) Metamorphism
d) Solomorphism
e) Inheritance

Ans. b. consider a base class B having a virtual function Foo, and a class D derived from this class also having a function Foo. Then when u create an object of a derived class, say dobj, and a ptr to base class, say pb, and point pb to dobj by saying pb = &dobj, and then call pb->Foo then the correct version of Foo will be called, i.e., the version in D will be called becz the object is of type D. this is called late binding, i.e., deferring the decision of calling which version of Foo until runtime since at compile time the type of object to which pb points may not be known.
class B {public: virtual void Foo(){cout<<"base";}};
class D : public B {public: virtual void Foo(){cout<<"derv";}};
D dobj;
B *pb;
pb = &dobj;

the output will be 'derv'.
If Foo was not declared virtual in base class B , then the output would have been 'base'.

class X
int x;
static void f(int z);
void X::f(int y) {x=y;}
What is the error in the sample code above?
a) The class X does not have any protected members.
b) The static member function f() accesses the non-static z.
c) The static member function f() accesses the non-static x.
d) The member function f() must return a value.
e) The class X does not have any private members.

Ans. c

template class Obj {
T my_t;
X my_x;
Obj(T t, X x) : my_t(t), my_x(x) { }
Referring to the sample code above, which one of the following is a valid conversion operator for the type T?
a) T operator T () { return my_t; }
b) T operator(T) const { return my_t; }
c) operator(T) { return my_t; }
d) T operator T (const Obj &obj) { return obj.my_t; }
e) operator T () const { return my_t; }

Ans. e.
this will be used for casting objects of type Obj to type T

class Myclass{};
template class Obj {
T my_t;
X my_x;
Obj(T t, X x) : my_t(t), my_x(x) { }
operator T () const { return my_t; }
operator X () const { return my_x; }

void main()
Myclass mt;
Obj myobj(10,mt);
int x = (int) myobj;
cout << x;
Myclass mobj = (Myclass) myobj;

catch(exception &e)
. . .
Referring to the sample code above, which one of the following lines of code produces a written description of the type of exception that "e" refers to?
a) cout << e.type();
b) cout <<;
c) cout << typeid(e).name();
d) cout << e.what();
e) cout << e;

Ans. c

int f() {
int I = 12;
int &r = I;
r += r / 4;
int *p = &r;
*p += r;
return I;
Referring to the sample code above, what is the return value of the function "f()"?
a) 12
b) 15
c) 24
d) 17
e) 30

Ans. e


1. b
2. c
3. b
4. b
5. b
6. b
7. b
8. a
9. e
10. d
11. e
12. b
13. e
14. e
15. b
16. b
17. c
18. e
19. c
20. e

C – Questions placement papers QUARK

C - Questions

1. What is the output of the following code
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. the output is QUARK test? Hello 12
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
int i,j,A;
for (A = -1;A<=1; 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?
int i=255;

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?
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

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 ?
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
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?


int * func(){
static int x=0;
x++; return &x;
int main()
int * y = func();
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;

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);}

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;

++x || ++y && ++z;

++x && ++y || ++z;

a. Compilation error.
b. Runtime error.
x=0 z=2
x=1 z=3
x=2 z=4
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 ?

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);
int * check(int i,int j )
int *p, *q;
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,

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?
char str1[]="Hello";
char str2[]="Hello";
if(str1= =str2&& (*(str1+6)= =*(str2+6)))
printf("\n Equal");
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
int a, b=255,c=127;
c=c^(~a & b|0);\
a. Error because of overflow;
b. 255
c. -256
d. 127
e. None of the above

Ans. d. 127


1. D
2. A
3. A
4. C
5. B
6. D
7. D
8. B
9. A
10. D
11. C
12. E
13. A
14. E
15. D
16. E
17. C
18. C
19. B
20. D