Latest topics
Search
C - Question Paper Quark Media House India Pvt. Ltd.
Page 1 of 1 • Share •
C - Question Paper Quark Media House India Pvt. Ltd.
1. What is the output of the following code
main()
{
printf("Hello %d",printf("QUARK test? "));
}
a. Compile time error.
b. Hello QUARK test?
c. Run time error.
d. None of the above.
e. Quark Test ?Hello.
2.) Out put of the following code is
main()
{
int i,j,A;
for (A = -1;A<=1; A++)
printf("%d\t",!!A);
}
a. 1 0 1
b. 65534 0 65534
c. -1 0 1
d. -65534 0 65534
e. None of the above
3) How long does this loop run: for(int x=0; x=3; x++)
a. Never
b. Three times
c. Forever
d. Once
e. None of the above
4) What shall be the output of the following code?
main()
{
char i = 'a';
printf("%c \t %c \t", i ,(++i));
}
a. a b
b. Compile time error
c. b b
d. a a
e. 65 66
5) What shall be the output of the following code?
main() {
int i,j;
printf(QUARK %s\n,main());
}
a. Compilation error.
b. Run-time error
c. Continuous scrolling Quark on the screen.
d. None of the above.
6) What shall be the output of the following code ?
#define f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a. 8
b. 64
c. 16
d. 12
7) What shall be the output of the following code ?
main()
{
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
fun1(temp);}
void fun1(void *temp1 )
{
int t1 = 0;
while(*((char*)temp1+ t1++ )!='\0') {
printf("%c",*((char*)temp1 + t1));
}
}
a. Compilation error
b. ark
c. quark
d. uark
8. What will be the out put of the following code?
void main()
{ int x=3;
printf("%d\t %d",x>>1, x<<3);
}
a. 1 and 4
b. 1 and 24
c. 1 and 27
d. None of the above
9. What will be the result of the following code?
int *x;
x =(int *) 15;
a. Compilation error
b. Compiles but gives a runtime error
c. Absolute location 15 in the memory space shall be assigned to pointer x;
d. Location 15 in the program space is assigned to pointer x;
e. Location 15 contains the address to an integer.
10. Which of the following functions cannot be called from another file?
a. const void func(){ ..}
b. extern void func(){ }
c. void func(){ }
d. static void func(){ .}
11. What will be the out come of the following code?
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();
12. 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);}
13. 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. All the above
e. None of the above.
14. 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);
15.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.
16. 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
17. 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.
18. 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.
19.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.
20. 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
ANSWERS
1. D
2. A
3. C
4. C
5. B
6. D
7. D
8. B
9. A
10. D
11. C
12. E
13. A
14. E
15. D
16. E
17. C
18. C
19. B
20. D
main()
{
printf("Hello %d",printf("QUARK test? "));
}
a. Compile time error.
b. Hello QUARK test?
c. Run time error.
d. None of the above.
e. Quark Test ?Hello.
2.) Out put of the following code is
main()
{
int i,j,A;
for (A = -1;A<=1; A++)
printf("%d\t",!!A);
}
a. 1 0 1
b. 65534 0 65534
c. -1 0 1
d. -65534 0 65534
e. None of the above
3) How long does this loop run: for(int x=0; x=3; x++)
a. Never
b. Three times
c. Forever
d. Once
e. None of the above
4) What shall be the output of the following code?
main()
{
char i = 'a';
printf("%c \t %c \t", i ,(++i));
}
a. a b
b. Compile time error
c. b b
d. a a
e. 65 66
5) What shall be the output of the following code?
main() {
int i,j;
printf(QUARK %s\n,main());
}
a. Compilation error.
b. Run-time error
c. Continuous scrolling Quark on the screen.
d. None of the above.
6) What shall be the output of the following code ?
#define f(x) x*x*x
main(){
printf("\n%d",f(2+2));
}
a. 8
b. 64
c. 16
d. 12
7) What shall be the output of the following code ?
main()
{
void fun1(void *);
char a[] = "quark";
void *temp;
temp = a;
fun1(temp);}
void fun1(void *temp1 )
{
int t1 = 0;
while(*((char*)temp1+ t1++ )!='\0') {
printf("%c",*((char*)temp1 + t1));
}
}
a. Compilation error
b. ark
c. quark
d. uark
8. What will be the out put of the following code?
void main()
{ int x=3;
printf("%d\t %d",x>>1, x<<3);
}
a. 1 and 4
b. 1 and 24
c. 1 and 27
d. None of the above
9. What will be the result of the following code?
int *x;
x =(int *) 15;
a. Compilation error
b. Compiles but gives a runtime error
c. Absolute location 15 in the memory space shall be assigned to pointer x;
d. Location 15 in the program space is assigned to pointer x;
e. Location 15 contains the address to an integer.
10. Which of the following functions cannot be called from another file?
a. const void func(){ ..}
b. extern void func(){ }
c. void func(){ }
d. static void func(){ .}
11. What will be the out come of the following code?
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();
12. 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);}
13. 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. All the above
e. None of the above.
14. 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);
15.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.
16. 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
17. 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.
18. 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.
19.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.
20. 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
ANSWERS
1. D
2. A
3. C
4. C
5. B
6. D
7. D
8. B
9. A
10. D
11. C
12. E
13. A
14. E
15. D
16. E
17. C
18. C
19. B
20. D
Admin- Admin
- Number of posts: 87
Age: 21
Registration date: 2007-11-08

Permissions of this forum:
You cannot reply to topics in this forum









» C - Question Paper Quark Media House India Pvt. Ltd.
» Simple Code in C which calls another exe file
» Cricket Game in C....Try this out...
» Calculator Program in PERL
» Airtel Music on C...Try This guys