Tuesday, May 21, 2013

C MCQ Test – 1

Que.1. Explain feature of stack.
A.    stack cannot reuse its memory
B.    All elements are of different data types
C.    All operations are at one end
D.    Any element can be accessed from it directly

Right Answer: C

Que.2. The compiler in C ignores all text from a _________ until then end of a line.
A.    /
B.    */
C.    **
D.    //

Right Answer: D

Que.3. What are the total number of keywords in C?
A.    30
B.    33
C.    32
D.    35

Right Answer: C

Que.4. What is the main difference between calloc() and malloc()?
A.    calloc() takes a single argument while malloc() needs two arguments
B.    malloc() takes a single argument while calloc()needs two arguments
C.    malloc() initializes the allocated memory to ZERO
D.    calloc() initializes the allocated memory to NULL

Right Answer: B

Que.5. rand() function returns a ___________ value
A.    float
B.    any type
C.    integer
D.    both a and c above

Right Answer: C

Que.6. Which of the following below is/are valid C keywords?
A.    integer
B.    int
C.    null
D.    both a and c above

Right Answer: B

Que.7. From which of the following libraries below, calloc() belongs to?
A.    stdlib.h
B.    malloc.h
C.    calloc.h
D.    both a and b above

Right Answer: D

Que.8. What is the purpose of getc() for?
A.    read a character from STDIN
B.    read a character from a file
C.    both a and b above
D.    read a character from an input of user

Right Answer: B

Que.9. What will be the output of the following program?
float x = 3.3;
int i;
i = (int) x;
print i;
A.    3
B.    3.3
C.    3.0
D.    3.00

Right Answer: A

Que.10. Exit() is same as return?
A.    Yes
B.    No

Right Answer: B

Que.11. With every use of a memory allocation function, what function should be used
To release allocated memory which is no longer needed?
A.    unallocated()
B.    dropmem()
C.    dealloc()
D.    release()
E.    free()

Right Answer: E

Que.12. What would be the output of the following?
main()
{
int val1=1234;
int val2=01234;
printf(“%d %d”, val1, val2);
}
A.    1234 1234;
B.    1234 01234;
C.    1234 668
D.    1234 688

Right Answer: C

Que.13¬ ¬¬__________ will immediately jump to the end of the current block of code
A.    continue
B.    Exit
C.    Goto
D.    break

Right Answer: E

Que.14. int testarray[3][2][2] = {
1,2,3,4,5,6,7,8,9,10,11,12}; What value does testarray[2][1][0] in the sample code
Above contain?
A.    3
B.    5
C.    7
D.    9
E.    11

Right Answer: E

Que.15. int I,j;
int ctr = 0;
int myArray[2][3];
for (i=0;i<3;i++)
for (j=0;j<2;j++)
{
myArray[j][i]=ctr;
++ctr;
}
What is the value of myArray[1][2]; in the sample code above?
A.    1
B.    2
C.    3
D.    4
E.    5

Right Answer: E

Que.16. int a=10,b;
v=a++ + ++A;
printf(“%d, %d, %d, %d”, b,a++,a,++a);
what will be the output when following code is executed
A.    12,10,11,13
B.    22,10,11,13
C.    22,11,11,11
D.    12,11,11,11
E.    22,13,13,13

Right Answer: E

Que.17. What would be the output of the following?
main(){
char *str=”eMississippiz”;
printf(“%s”,str);
}
A.    eMississippiz
B.    eMissi ssippiz
C.    Mississippi
D.    Missi

Right Answer: A

Que.18. In C, what is the difference between a declaration and definition of a variable?
A.    Both can occur multiple times, but a declaration must occur first.
B.    Both can occur multiple times, but a definition must occur first.
C.    A definition occurs once, but declaration may occur many times.
D.    A declaration occurs once, but definition may occur many times.

Right Answer: C

Que.19. Which one of the following functions is the correct choice for moving blocks of
binary data that are of arbitrary size and position in memory?
A.    memcpy()
B.    memset()
C.    strcpy()
D.    strcpy()
E.    memove()

Right Answer: E

Que.20. Can getch() be used to echo the input?
A.    Yes
B.    No

Right Answer: B

No comments:

Post a Comment