C Language Interview Question

There are many things that you can do ahead of time to prepare for the interviewing process, and move yourself a step above of the competition. Updating your resume and reviewing frequently asked interview questions can be very effective, and goes a long way in getting the most out of your interview.

WHat will be the result of the following code?

#define TRUE 0 // some code while(TRUE) { // some code }
This will not go into the loop as TRUE is defined as 0.

 

What will be printed as the result of the operation below:

int x;
int modifyvalue()
{
return(x+=10);
}

int changevalue(int x)
{
return(x+=1);
}

void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%d\n",x);

x++;
changevalue(x);
printf("Second output:%d\n",x);
modifyvalue();
printf("Third output:%d\n",x);

}



Answer: 12 , 13 , 13

 

What will be printed as the result of the operation below:

main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf(“%d %d\n”,x,y);

}


Answer: 11, 16

 

What will be printed as the result of the operation below:

main()
{
int a=0;
if(a==0)
printf(“Tech Preparation\n”);
printf(“Tech Preparation\n”);

}


Answer: Two lines with “Tech Preparation” will be printed.

 

What will the following piece of code do

int f(unsigned int x)
{
int i;
for (i=0; x!0; x>>=1){
if (x & 0X1)
i++;
}
return i;
}


Answer: returns the number of ones in the input parameter X