Sie sind auf Seite 1von 13

C Test Paper

1. main()
{
printf(\n%d %d %d ,sizeof(3),sizeof(3),sizeof(3));
}
a. 1 1 1
c. 1 2 2

b. 2 2 2
d. Compiler Dependent

2. Declare a function pointer which takes a pointer to char as an argument and


returns a void pointer
a.
b.
c.
d.

void
void
void
void

(funptr)(char *)
* (funptr)(char *)
* (*funptr)(char)
* (*funptr)(char *)

3. What is the following program doing?


main()
{
unsigned int m[]={0x01,0x02,0x04,0x08,0,10,0x20,0x40,0x80};
unsigned char n,I;
scanf (%d, &n);
for(i=0;i<=7;i++)
{
if(n & m[i])
printf(\nYes);
}
}
a.
b.
c.
d.
4.

Putting off all bits which are on in the number n


Testing whether the individual bits of n are on or off
This program would give an error
None of the above

main()
{
const int x=5;
int *ptrx;
ptrx = &x;
*ptrx = 10;
printf(%d,x);
}
A.5

B.10

C. Error

D. Garbage value

5. #define STR1 int*


void main()
{
typedef int* STR2;
STR1 sample1,sample2;
STR2 sample3,sample4;
int a=5;
Sample1=&a;
sample2=&a;
sample3=&a;
sample4=&a;
printf("%d",*sample1);
printf("%d ",*sample2);
printf("%d ",*sample3);
printf("%d ",*sample4);

}
A. 5 5 5 5
B. Cannot convert int to int *
C. Invalid indirection
D. Both B and C
6. If we ask realloc to increase the allocated space, would it increase the space at the
same location or would it try to find a different place?

A.
B.
C.
D.

Same place
Different place
First try at the same place than if not possible at different place.
will not increase the space itself

7.
main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf(%u %u,j,k);
}
A. 11 11

B. Compile Time Error

C.11 10

D. Link Time Error

8. Specify the output of the program if compiled and run under linux
main()
{
int *ptr=NULL;
printf(%d,*ptr);
}
A.
B.
C.
D.

Compile time error


Link Time Error
Garbage value
Segmentation Fault

9. static variables are


A.
B.
C.
D.

Load Time variables


Unload Time Variables
Compile Time Variables
Link Time Variables

10. A variable whose value can be changed by background routines is known as


A.
B.
C.
D.

Local Variables
Static Variables
Extern Variables
Volatile Variables

11. What is the difference between char a[] = "string"; and

char *p = "string";
A. Nothing

B. The first declares an initialized and modifiable array;


The second declares a pointer initialized to a notnecessarily-modifiable constant string
C. The first declares an initialized and modifiable array; the
second declares a pointer initialized to a not-necessarilymodifiable constant string in stack.
D. The first declares an initialized and modifiable array; the
second declares a pointer initialized to a not-necessarilymodifiable constant string in Heap.

12.

What is a Self Referential Structure


A.
B.
C.
D.

13.

A structure containing pointer to different structure


A structure containing pointer to itself
A Structure having a pointer to anything
A structure whose pointer is created

Specify the output


main()
{
int i=7;
printf(%d,i++ * i++);
}
A.
B.
C.
D.

49
56
81
Compiler dependent

14. What does the following declaration specify


struct foo {
int x;
}
fun()
{
Statements;

}
A.
B.
C.
D.

a function returning int and a structure foo declaration


a function returning a structure foo
a function returning pointer to structure foo
a structure having a function fun as its member

15. Whats wrong in the following program


Main()
{
Char *s=malloc;
char *r;
strcpy (r, s);
}
A.
B.
C.
D.

s has not been allocated memory


r has not been allocated memory
we cannot give malloc as a string data
Nothing wrong in the program

16. Specify output


void main()
{
char far *aaa=(char far *)0x0000ffff;
printf("B4 incrementing the address of aaa=%Fp\n",aaa);
aaa++;
printf("After inc the add ,address of aaa=%Fp",aaa);
}
A.
B.
C.
D.

0x00010000
Program terminates
0x00000000
Compile Time Error

17. Global and Static variables are stored at


A.
B.
C.
D.

Beginning of Data Segment


End of Data Segment
Beginning of Code Segment
Inside Stack

18. What is a sequence point?


A. any point in a programs execution wherein all side effects of previous
evaluations are complete and no side effects of subsequent evaluations have
started
B. A point where break point is set
C. A place where the sequence of execution of the program is unpredictable
D. All of the above

19.

The compiler can automatically calculate the memory space needed by an


unsized integer array
A.
B.
C.
D.

Always in case of single dimensional arrays


Only in case of double dimensional arrays
Both A and B
None of above

20. What's wrong with "char *p; *p = (char *)malloc(10);"?

A.
B.
C.
D.

Nothing wrong
We cannot use a constant value inside malloc
*p must be replaced by p
Both B and C

21. Considering the Little Endian processor, specify the output


main()
{
int data=0x4142;
char *p;
p=(char *)&data;
(*p)++;
printf("%c",*p);
}
A.
B.
C.
D.

A
B
C
Garbage value

22. What is an external node?


A.
B.
C.
D.

A node without any children


A leaf node
A node with children
Both A and B

23. What does *p++ increment?


A. The value being pointed to by P
B. The address contained in P
C. Syntax Error
D. Both A and B

24. Specify the sequence points in a for loop as described below


for ( i=0 ; i<=10 ; i++)
A.
B.
C.
D.

i=0
i<=10
i++
All of the above

25. Which one out of NULL and 0 should be used to initialize pointers?

A. NULL
B. 0
C. None
D. Either; the distinction is entirely stylistic
26. In what way out of the following the Post order traversal mechanism
can be best used for

A. Reading a document from beginning to end


B. Disk usage
C. Printing an arithmetic expression
D. None of the Above
27.

What is the traverse order followed by Pre-Order mechanism


A.
B.
C.
D.

28.

Out of the following searching algorithms follows the divide and conquer
strategy
A.
B.
C.
D.

29.

Left->Root->Right
Root->Left->Right
Left->Right->Root
Root->Right->Left

Sequential search
Binary Search
Linear Search
Selection Search

Which of the following sorting algorithms uses the divide and conquer strategy
A.
B.
C.
D.

Heap Sort
Insertion Sort
Merge Sort
Bubble Sort

30.

Static allocation of memory is performed at


A.
B.
C.
D.

31.

Which of the following functions can by used in TurboC++ compiler to activate


the DOS interrupt
A.
B.
C.
D.

32.

Run Time
Compile Time
Link Time
Load Time

int86
int86X
intdos
All of the above

What does the following declaration signify


int (*funptr)[10]
A.
B.
C.
D.

33.

An array of ten elements containing pointers to functions returning int


A pointer to an array of ten elements containing function pointers
A pointer to an array of 30 integers
Both A and B

What will be the output of the following program in linux


main()
{
int *ptr;
*ptr=10;
printf(%d,*ptr);
}
A.
B.
C.
D.

34.

Compilation Error
10
Segmentation fault
0

What is meant by Unspecified behavior(Choose the closest definition)


A. Behavior of a correct construct and correct data, for which the language
imposes no requirement
B. Use of an erroneous construct or erroneous data, for which the language
imposes no requirement

C. A construct that produces erroneous results or terminates abnormally


when compiled, linked and executed elsewhere
D. Behavior of a correct construct and correct data, that varies with each
implementation, but must be documented
35.

Which of the following pointers are 32 bit


A.
B.
C.
D.

Near
Huge
Far
Both B and C

36.
main()
{
Char *p=Hello;
printf(%s,p);
}
Considering the TurboC++ compiler, where will the string Hello be stored in the
Data Segment?
A.
B.
C.
D.

Uninitialized section
Stack
Initialized Section
Both B and C

37. Specify the exact output of the following programs considering TurboC++
compiler
main()
{
int a=10,b=20;
int c[2];
c[0]=100; c[1]=200; c[2]=300;c[3]=400;
printf("%d %d",a,b);
}
A.
B.
C.
D.

10,20
400,300
300,400
300,20

38.

Specify the output of the following program


#include<stdio.h>
#include<string.h>
#include<conio.h>
#pragma startup start
#pragma exit
end
void start();
void end();
void main()
{
printf("Inside main,");
}
void start()
{
printf("Before main,");
}
void end()
{
printf("Exiting,");
}
A.
B.
C.
D.

Inside main, Before main, Exiting


Before main, Inside main, Exiting
Compilation Error
Before main, Exiting, Inside main

39. Chaining is a technique used to over come


A.
B.
C.
D.

Function calls overhead


Overhead caused by macro substitution
Collision in hashing
Array out of bound error

40. The device mapped at address 0xB0008000 falls under


A.
B.
C.
D.

Memory mapped device


I/O mapped device
None of the above
Depends on the OS

41.

Trace the error in the following program


#include<stdio.h>
int main()
{
struct bit_field {
int bit_1
: 1;
int bits_2_to_5 : 4;
int bit_6
: 1;
int bits_7_to_16 : 10;
int bits_17_to_32 : 16;
} bit_var;
}
A. No Problem
B. A structure cannot contain all together more than 16 bits where the above
structure consists of 32 bit
C. The last element contains 16 bits which is not allowed
D. Two elements consist of 1 bit that is not allowed

42.

What data types can be used to represent processor registers


A.
B.
C.
D.

43.

Structure
Union
Both A and B
None of the above

Which of the following suits best for the Big-Endian architectures


A. The most significant value in the sequence is stored at the lowest storage
address
B. The most significant value in the sequence is stored at the highest storage
address
C. The least significant value in the sequence is stored at the lowest address
D. Both A and C

44.

What does the second argument of Keep function signify


A.
B.
C.
D.

45.

Number of bytes to be reserved


Number of paragraphs to be reserved
Number of Words to be reserved
Number of Double Words to be reserved

What is the address at which the ISR of keyboard is stored (Consider Turbo
C++ )
A.
B.
C.
D.

46.

Whats the chip serializing the interrupt to the processor known as


A.
B.
C.
D.

47.

32
36
35
39

Interrupt Priority controller


Priority Interrupt Controller
Programmable Interrupt Controller
Both A and B

Specify the output of the following program


main()
{
int result;
asm mov ax,20
asm mov bx,10
asm add ax,bx
mov result,ax
printf("%d",result);
}
A.
B.
C.
D.

30
Garbage value
Compilation Error
None of the above

48.

Under which category does the printf function fall under


A.
B.
C.
D.

49.

Functions with constant number of arguments


Functions with integer number of arguments
Functions with Known number of arguments
Functions with variable number of arguments

What does "Segmentation violation" mean?


A. You have accessed a different segment in 8086 in the large memory model
other than the one where your Data segment is pointing to
B. Program tried to access memory it shouldn't have, invariably as a result of
stack corrupt
C. Program tried to access memory it shouldn't have, invariably as a result of
improper pointer use
D. Both B and C

50.

The struct WORDREGS and BYTEREGS are a member of


A.
B.
C.
D.

struct REGS
union REGS
struct SREGS
union SREGS

Das könnte Ihnen auch gefallen