Subscribe:Posts Comments | Read Articles on Various Topics - Pro Articles

By PDMACpayday loans

You Are Here: Home » Quark Test Papers, Sample Placement Papers » Quark Sample Placement Paper Technical C Skills

Quark India Placement Paper sample C programming language multiple choice questions from the Technical Tech Section of the question paper:

1. What will be the out come of the following code?

#include

int * func(){
static int x=0;
x++; return &x;
}
int main()
{
int * y = func();
printf(“%d”,(*y)++);
func();
printf(“%d\n”,*y);
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

2. Referring to the above code , which of the following would be the correct
implementation for myFunc ?
char *format = “%d”;
int main()
{
int x;
myFunc(scanf,&x);
printf(“%d\n”,x);
return(0);
}

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

3. 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.

4. 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);

5.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;
PRINTXYZ(x,y,z);

++x || ++y && ++z;
PRINTXYZ(x,y,z);

++x && ++y || ++z;
PRINTXYZ(x,y,z);
}

a. Compilation error.
b. Runtime error.
c.
x=0 z=2
x=1 z=3
x=2 z=4
d.
x=0 z=2
x=1 z=2
x=2 z=3
e. None of the above.

Ans. d.

6. What shall be the output of the following code ?

main()
{
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.

7. 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);
printf(“\nc=%u”,c);
}
int * check(int i,int j )
{
int *p, *q;
p=&i;
q=&j;
if(i>=95)
return(q);
else
return(p);
}
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.

8. What shall be the output of the following code?

void main()
{int a[3][2]={ 1,2,
5,7,
6,8};

printf(“\n%d”,((a+1)-(&a+1)));
}
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.

9.What shall be the output of the following code?
main()
{
char str1[]=”Hello”;
char str2[]=”Hello”;
if(str1= =str2&& (*(str1+6)= =*(str2+6)))
printf(“\n Equal”);
else
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.

10. Given that sizeof(int) is 2 , what is the output of the following code
main()
{
int a, b=255,c=127;
a=~b;
c=c^(~a & b|0);\
c=c^(~(~b));
printf(“%d\n”,c);
}
a. Error because of overflow;
b. 255
c. –256
d. 127
e. None of the above
Ans. d. 127

Quark India develops world class software for the publishing industry. Its well known through out the world for its suite of publisher software products. Quark is present in Mohali – Panchkula Punjab, India. Its campus has many engineers from all branches like electronics, computer science and IT working as developers and support executives. It was also recently in the news for developing a new township called Quark City. See related detailed placement exam whole test papers for joint campus recruitment of engineers – electrical, mechanical, cse, ece, etc. and hr technical tech interview questions.

Leave a Reply

© Copyright 2010 Latestexams. All Rights Reserved | Privacy Policy | Terms & Conditions