eg: IT, BANK, MECHANICAL, etc..

HCL Solved placement Papers - C questions - part 2

How Placement Success Book
(Hard Copy) Can Help Your Preparation?

Dear Reader, you can now prepare simultaneously for placement tests of several companies like TCS, Wipro, HCL, Infosys, CTS, Syntel, Mahindra Satyam, L&T Infotech, IBM, 3i Infotech, Accenture & other leading Indian companies...

Click To Know How Placement Success Book (Hard Copy)Can Help You...

Here are some solved questions from HCL Placement Papers

1) #include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
}

Answer:

Compiler Error
Explanation:
Initialization should not be done for structure members inside the structure declaration

2) main()
{
 int *j;
{
 int i=10;
 j=&i;
}
 printf("%d",*j);
}

Answer:
10
Explanation:
The variable i is a block level variable and the visibility is inside that block only. But the lifetime of i is lifetime of the function so it lives upto the exit of main
function. Since the i is still allocated space, *j prints the value stored in i since j points i.

3) int i,j;
 for(i=0;i<=10;i++)
 {
 j+=5;
assert(i<5);
}

Answer:

Runtime error: Abnormal program termination.  assert failed (i<5), ,

Explanation:
asserts are used during debugging to make sure that  certain conditions are satisfied. If assertion fails, the program will terminate reporting the same. After debugging use,
 #undef NDEBUG and this will disable all the assertions from the source code. Assertion is a good debugging tool to make use of..

4)  main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}

Answer:
1
Explanation:
Scanf returns number of items successfully read and not 1/0. Here 10
is given as input which should have been scanned successfully. So
number of items read is 1.

Dear CV Reader, Are You Preparing Seriously For Your Placement Tests ?

Click Here To Know What Placement Success Book (Hard Copy) Contains & Know How To Order This Book



Jobs, Placement Papers

Welcome to Placement papers and jobs help portal. Here you can find previous placement questions, sample placement papers, job interview questions and other material pertaining to top Indian companies like Infosys, Wipro, HCL, Satyam, TCS, HCL, HP, Accenture etc.
We are constantly striving to provide you the latest job openings and placement papers and services available from India.

  • Fresher IT Jobs
  • Bank & Finance Jobs
  • Experienced IT Jobs
  • Mechanical Jobs


Footer Links