Home »» Placement Papers »» All Papers »» HCL »» Placement Paper

HCL Technical Questions - Placement Papers


The technical section of HCL includes questions based on C programing, data structures and C++.

Here are a few questions asked in the technical section of HCL:

1. Which type of the controlling expression of a switch statement cannot be of the type?

a) int 
b) char 
c) short 
d)float 
e) none

2. Where is Key value pair seen?

a) Hash tables
b) Heaps
c) Both a and b
d) None of the above
e) Only in heaps

3. What is the output of the following problem?

#define INC(X) X++
main()
{
int X=4;
printf("%d",INC(X++));
}

a) compilation error 
b) runtime error 
c)6 
d) 4 
e) 5

4. What can be said of the following?

struct Node {
char *word;
int count;
struct Node left;
struct Node right;
}

a) structures cannot refer to other structure
b) Incorrect definition
c) Structures can refer to themselves. Hence the statement is OK
d) Structures can refer to maximum of one other structure

5. When do we get segmentation fault error? 

a) Accessing an array out of its bounds
b) Trying to modify a read-only location
c) Dereferencing an uninitialized pointer
d) Only a and b
e) All of the above


6. What is the output of the following program

main()
{
int a=11;
int b=5;
if(a=3)
b++;
printf("%d %dn",a,b++);
}

a) 11,5 
b)10,7 
c) 3,6 
d) 3,7 
e) none


7. What can be said of the following program?

main()
{
enum Days {MON =1,TUE,WED,THU};
Months X = MON;
if(X==1)
{
printf("Mon is the first day");
}
}

a) Does not print anything
b) Prints : Mon is the first day
c) Generates compilation error
d) Results in runtime error


8. What is the output of the following program?

main()
{
char *src = "Hello People";
char dst[100];
strcpy(src,dst);
printf("%s",dst);
}strcpy(char *dst,char *src)
{while(*src) *dst++ = *src++;
}

a) "Hello People" 
b)"Hello" 
c)"People" 
d) NULL 
e) unidentified

9 .What is the output of the following program?

main()
{
int l=6;
switch(l)
{ default : l+=2;
case 4: l=4;
case 5: l++;
break;
}
printf("%d",l);
}

a) 8 
b) 6 
c) 5 
d) 4 
e)none

10.What is the output of the following program?

main()
{
int a=20;
int b=10;
swap(a,b);
printf("%d %d",b,a+2);
}
swap(int a,int b)
{
int temp;
temp =a;
a=b;
b=temp;
}

a)10,20 
b) 20,12 
c) 22,10 
d)10,22 
e)none 

11. Which of the following about the following two declaration is true

i ) int *F()
ii) int (*F)()

a) Both are identical
b) The first is a correct declaration and the second is wrong
c) The first declaraion is a function returning a pointer to an integer and the second is a pointer to function returning int
d) Both are different ways of declarin pointer to a function

12. What are the values printed by the following program?

#define dprint(expr) printf(#expr "=%dn",expr)
main()
{
int a=7;
int b=3;
dprintf(a/b);
}

a) #2 = 2 
b) expr=2 
c) a/b=2 
d) none 

13. Output of the following.

main()
{
int i;
char *p;
i=X89;
p=(char *)i;
p++;
printf("%xn",p);
}

a) X8A
b) N p
c) Qu
d) 890
e) qp

14. Which of the following is not a ANSI C language keyword?

a) Herp
b) Heal
c) Key
d) Mouse
e) Function.

15. What are the machine registers called?

a) Local variables
b) Global variables
c) Static Variables
d) Contants
e) None of the above

16. When an array is passed as parameter to a function, which of the following statement is correct choice:

a) The function can change values in the original array
b) Results in a run time error when the function tries to access the elements in the array
c) It results in compilation error when the function tries to access the elements in the array
d) In C parameters are passed by value. The function cannot change the original value in the array

Comment

0 Answers