Wednesday 28 September 2011

HCL Placement Paper Technical paper Pune 2010

1. The C language terminator is

(a) semicolon
(b) colon
(c) period
(d) exclamation mark

2. What is false about the following — A compound statement is

(a) A set of simple statements
(b) Demarcated on either side by curly brackets

(c) Can be used in place of simple statement
(d) A C function is not a compound statement.

3. What is true about the following C Functions

(a) Need not return any value
(b) Should always return an integer
(c) Should always return a float
(d) Should always return more than one value


4. Main must be written as

(a) The first function in the program
(b) Second function in the program
(c) Last function in the program
(d) Any where in the program



5. In signed magnitude notation what is the minimum value that can be represented with 8 bits




(a) -128

(b) -255

(c) -127

(d) 0


6.

struct Foo


{

char *pName;

char *pAddress;

};
main()

{

struct Foo *obj = malloc(sizeof(struct Foo));

clrscr();

obj->pName = malloc(100);


obj->pAddress = malloc(100);
strcpy(obj->pName,”Your Name”);

strcpy(obj->pAddress, “Your Address”);
free(obj);

printf(“%s”, obj->pName);


printf(“%s”, obj->pAddress);

}
a. Your Name, Your Address

b. Your Address, Your Address

c. Your Name Your Name

d. None of the above

Ans: d) printd Nothing, as after free(obj), no memory is there containing


obj->pName & pbj->pAddress


7.

main()

{

char *a = “Hello “;


char *b = “World”;

clrscr();

printf(“%s”, strcat(a,b));

}
a. Hello

b. Hello World

c. HelloWorld


d. None of the above

Ans: b)


8.
main()

{

char *a = “Hello “;


char *b = “World”;

clrscr();

printf(“%s”, strcpy(a,b));

}
a. “Hello”

b. “Hello World”

c. “HelloWorld”


d. None of the above
Ans: d) World, copies World on a, overwrites Hello in a.

9.

void func1(int (*a)[10])

{

printf(“Ok it works”);

}

void func2(int a[][10])

{

printf(“Will this work?”);

}
main()

{

int a[10][10];

func1(a);


func2(a);

}
a. Ok it works

b. Will this work?

c. Ok it worksWill this work?

d. None of the above
Ans: c)

10.


main()

{

printf(“%d, %d”, sizeof(‘c’), sizeof(100));

}
a. 2, 2

b. 2, 100

c. 4, 100


d. 4, 4
Ans: a) 2, 2


11.

main()

{

int i = 100;

clrscr();


printf(“%d”, sizeof(sizeof(i)));

}
a. 2

b. 100

c. 4

d. none of the above

Ans: a) 2



12.
main()

{

int c = 5;

printf(“%d”, main||c);

}
a. 1


b. 5

c. 0

d. none of the above
Ans: a) 1, if we use main|c then error, illegal use of pointer

13.
main()

{

char c;

int i = 456;


clrscr();

c = i;

printf(“%d”, c);

}
a. 456

b. -456

c. random number

d. none of the above

Ans: d) -56


14.

void main ()

{

int x = 10;

printf (“x = %d, y = %d”, x,–x++);


}
a. 10, 10

b. 10, 9

c. 10, 11

d. none of the above

Ans: d) Lvalue required


15.


main()

{

int i =10, j = 20;

clrscr();

printf(“%d, %d, “, j– , –i);

printf(“%d, %d “, j++ , ++i);


}
a. 20, 10, 20, 10

b. 20, 9, 20, 10

c. 20, 9, 19, 10

d. 19, 9, 20, 10
Ans: c)

0 comments:

Post a Comment

INDIA ENOW

How do u rate my blog?

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More