You are on page 1of 21

C Multiple Choice Questions

Page 1 2 >>>
Question No. 1 -->
void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
What is the output?

1) XAM is printed
2) exam is printed
3) Compiler Error
4) Nothing is printed

See Answer(s) of Question no. 1

Question No. 2 -->


What is the result of 16>>2?

1) 4
2) 8
3) 3
4) 0

See Answer(s) of Question no. 2

Question No. 3 -->


What is the output of the following code?
#include<stdio.h>
void main()
{
char letter =`Z`;
printf("\n%c",letter);
}

1) Z
2) 90
3) Error
4) Garbage Value

See Answer(s) of Question no. 3


Question No. 4 -->
What is the output of the following code?
#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s<4 && s<9)
continue;
printf("\n%d\t",s);
}
}

1) 1 2 3 4 5 6 7 8 9
2) 1 2 3 10
3) 4 5 6 7 8 9 10
4) 4 5 6 7 8 9

See Answer(s) of Question no. 4

Question No. 5 -->


What is the output of the following code?
# include<stdio.h>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}

1) 10..10
2) 10..50
3) Error
4) 0

See Answer(s) of Question no. 5

Question No. 6 -->


Array passed as an argument to a function is interpreted as

1) Address of the array


2) Values of the first elements of the array
3) Address of the first element of the array
4) Number of element of the array

See Answer(s) of Question no. 6

Question No. 7 -->


How can I dynamically allocate a two-dimensional array?

1) int **array1 = (int **)malloc(nrows * sizeof(int *));


for(i = 0; i < nrows; i++)
array1[i] = (int *)malloc(ncolumns * sizeof(int));

2) int **array2 = (int **)malloc(nrows * sizeof(int *));


array2[0] = (int *)malloc(nrows * ncolumns * sizeof(int));
for(i = 1; i < nrows; i++)
array2[i] = array2[0] + i * ncolumns;

3) int *array3 = (int *)malloc(nrows * ncolumns * sizeof(int));

4) Any of the above.

See Answer(s) of Question no. 7

Question No. 8 -->


main()
{
char thought[2][30]={"Don`t walk in front of me..","I am not follow"};
printf("%c%c",*(thought[0]+9),*(*(thought+0)+5));
}
What is the output of this program?

1) k k
2) Don`t walk in front of me
3) I may not follow
4) K

See Answer(s) of Question no. 8

Question No. 9 -->


#include <stdio.h>
void main()
{
int I=3,*j,**k;
j=&I;
k=&j;
printf("%d%d%d",*j,**k,*(*k));
}
What is the output of the above program code?
1) 444

2) 000

3) 333

4) 433

See Answer(s) of Question no. 9

Question No. 10 -->


Which of the following is the correct way of declaring a float pointer:

1) float ptr;
2) float *ptr;
3) *float ptr;
4) None of the above

See Answer(s) of Question no. 10

Question No. 11 -->


The reason for using pointer is ...
Choose the false option from the following sentences

1) Accessing arrays or string elements


2) Dynamic memory allocation
3) Implementing linked list,trees,graphs and many other data structures
4) All are false

See Answer(s) of Question no. 11

Question No. 12 -->


The size of a structure can be determined by
a. size of variable name
b. size of (struct tag)

1) Only a
2) Only b
3) Both a and b
4) None of these options

See Answer(s) of Question no. 12


Question No. 13 -->
main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?

1) program will not compile


2) 10
3) god only knows
4) address of I

See Answer(s) of Question no. 13

Question No. 14 -->


Pushdown list means:

1) Stack
2) Queue
3) Linked list
4) All of the above

See Answer(s) of Question no. 14

Question No. 15 -->


What is time required to insert an element in a stack with linked implementation?

1) O(

1)
2) O(log2n)
3) O(n)
4) O(n log2n)

See Answer(s) of Question no. 15

Question No. 16 -->


Which of the following is the feature of stack?

1) All operations are at one end


2) It cannot reuse its memory
3) All elements are of different data types
4) Any element can be accessed from it directly
See Answer(s) of Question no. 16

Question No. 17 -->


To create a linked list, we can allocate space and make something point to it, by writing:
struct-name *pointer-variable;
Which of the following statement will correctly allocate the space

1) pointer-variable = malloc(sizeof(*struct-name));
2) pointer-variable = malloc(sizeof(struct struct-name));
3) pointer-variable = alloc(sizeof(struct struct-name));
4) pointer-variable = alloc(sizeof(*struct-name));

See Answer(s) of Question no. 17

Question No. 18 -->


What result is achieved through the following code snippet?
int initialize(NODE **circle)
{
if ((*circle = (NODE *)malloc(sizeof(NODE))) == NULL)
return 0;
(*circle)->next = NULL;
(*circle)->previous = NULL;
return 1;
}

1) The node circle is assigned to NULL


2) The size of the node circle is assigned to NULL
3) Both the pointers next and previous are assigned to NULL
4) None of these options

See Answer(s) of Question no. 18

Question No. 19 -->


What would be the output of the following program?
#include <stdio.h>
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}

1) 7
2) 6
3) 5
4) error
See Answer(s) of Question no. 19

Question No. 20 -->


fputs function is used to
i. write characters to a file
ii. takes 2 parameters
iii. returns a character
iv. requires a file pointer

1) all are true


2) all are false
3) only i and ii are true
4) only i,ii and iv are true

See Answer(s) of Question no. 20

Question No. 21 -->


#include <stdio.h>
void main()
{
int a; printf("%d",a^a);
}
1) 1
2) 0
3) Unexpected
4) Runtime Error

See Answer(s) of Question no. 21

Question No. 22 -->


Time taken for addition of element in queue is

1) O(1)
2) O(n)
3) O(log n)
4) None of these options

See Answer(s) of Question no. 22

Question No. 23 -->


To delete a dynamically allocated array named `a`, the correct statement is

1) delete a;
2) delete a[0];
3) delete []a;
4) delete [0]a;
See Answer(s) of Question no. 23

Question No. 24 -->


An entire structure or union variable can be assigned to another structure or union
variable if

1) The two variables have the same composition.


2) The two variables are of same type.
3) Assignment of one structure or union variable to another is not possible.
4) None of these options

See Answer(s) of Question no. 24

Question No. 25 -->


What is the output of the following code?
#include<stdio.h>
void swap(int&, int&);
void main()
{
int a = 10,b=20;
swap (a++,b++);
printf("\n%d\t%d\t",a, b);
}
void swap(int& x, int& y)
{
x+=2;
y+=3;
}

1) 14, 24
2) 11, 21
3) 10, 20
4) Error

See Answer(s) of Question no. 25

Question No. 26 -->


What will be the value of `a` after the following code is executed
#define square(x) x*x
a = square(2+3)
1) 25
2) 13
3) 11
4) 10

See Answer(s) of Question no. 26


Question No. 27 -->
The five items: A, B, C, D and E are pushed in a stack,one after the other starting from
A. The stack is popped four times and each element is inserted in a queue. Then two
elements are deleted from the queue and pushed back on the stack. Now one item is
popped from the stack.
The popped item is.

1) A
2) B
3) C
4) D

See Answer(s) of Question no. 27

Question No. 28 -->


What is the output of the following code?
#include<stdio.h>
void main()
{
int a=0,b=0;
a = (b = 75) + 9;
printf("\n%d, %d",a, b);
}
1) 75, 9
2) 75, 84
3) 84, 75
4) None of these options

See Answer(s) of Question no. 28

Question No. 29 -->


Object Oriented Technology`s use of _________ facilitates the reuse of the code and
architecture and its __________ feature provides systems with stability, as a small
change in requirements does not require massive changes in the system:

1) Encapsulation; inheritance
2) Inheritance; polymorphism
3) Inheritance; encapsulation
4) Polymorphism; abstraction

See Answer(s) of Question no. 29

Question No. 30 -->


A recursive function would result in infinite recursion, if the following were left out:

1) Base case
2) Recursive call
3) Subtraction
4) Local variable declarations

See Answer(s) of Question no. 30

Question No. 31 -->


Which of the following are class relationships?

1) is-a relationship.
2) Part-of relationship.
3) Use-a relationship.
4) All of these options.

See Answer(s) of Question no. 31

Question No. 32 -->


In OOP`s, advantage of inheritance include.

1) Providing a useful conceptual framework.


2) Avoiding rewriting a code.
3) Facilitating class libraries.
4) All of these options.

See Answer(s) of Question no. 32

Question No. 33 -->


What is inheritance?

1) It is same as encapsulation.
2) Aggregation of information.
3) Generalization and specialization.
4) All of these options.

See Answer(s) of Question no. 33

Question No. 34 -->


Object orientated programming allows for extension of an objects function or of class
function. This ability within OOP is called ________________ .

1) extendibility
2) expansion capacity
3) virtual extension
4) scalability

See Answer(s) of Question no. 34


Question No. 35 -->
UML stands for

1) Unique modeling language.


2) Unified modeling language
3) Unified modern language
4) Unified master laqnguage

See Answer(s) of Question no. 35

Question No. 36 -->


Which of the following programming technique focuses on the algorithm.

1) Procedural language
2) Object oriented language
3)Object based language
4) Structural language

See Answer(s) of Question no. 36

Question No. 37 -->


_______ provide useful conceptual framework.

1) Inheritance
2) Polymorphysm
3) Encapsulation
4) None of these options

See Answer(s) of Question no. 37

Question No. 38 -->


Which of the following is true:

1) Class is an object of an object.


2) Class is meta class.
3) Class cannot have zero instances.
4) None of these options.

See Answer(s) of Question no. 38

Question No. 39 -->


The design of classes in a way that hides the details of implementation from the user is
known as:

1) Encapsulation
2) Information Hiding
3) Data abstraction
4) All of these options

See Answer(s) of Question no. 39

ANSWERS -->

Answer of Question No. 1 -->


void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
What is the output?
4) Nothing is printed   <ANS>

Goto Question no. 1

Answer of Question No. 2 -->


What is the result of 16>>2?

1) 4
2) 8
3) 3
4) 0

Goto Question no. 2

Answer of Question No. 3 -->


What is the output of the following code?
#include<stdio.h>
void main()
{
char letter =`Z`;
printf("\n%c",letter);
}

1) Z   <ANS>

Goto Question no. 3

Answer of Question No. 4 -->


What is the output of the following code?
#include<stdio.h>
void main()
{
int s=0;
while(s++<10)
{
if(s<4 && s<9)
continue;
printf("\n%d\t",s);
}
}

3) 4 5 6 7 8 9 10   <ANS>

Goto Question no. 4

Answer of Question No. 5 -->


What is the output of the following code?
# include<stdio.h>
# define a 10
main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
void foo()
{
#undef a
#define a 50
}

1) 10..10   <ANS>

Goto Question no. 5

Answer of Question No. 6 -->


Array passed as an argument to a function is interpreted as
3) Address of the first element of the array   <ANS>

Goto Question no. 6

Answer of Question No. 7 -->


How can I dynamically allocate a two-dimensional array?

1) int **array1 = (int **)malloc(nrows * sizeof(int *));


    for(i = 0; i < nrows; i++)
    array1[i] = (int *)malloc(ncolumns * sizeof(int));

2) int **array2 = (int **)malloc(nrows * sizeof(int *));


    array2[0] = (int *)malloc(nrows * ncolumns * sizeof(int));
    for(i = 1; i < nrows; i++)
    array2[i] = array2[0] + i * ncolumns;

3) int *array3 = (int *)malloc(nrows * ncolumns * sizeof(int));

4) Any of the above.

Goto Question no. 7

Answer of Question No. 8 -->


main()
{
char thought[2][30]={"Don`t walk in front of me..","I am not follow"};
printf("%c%c",*(thought[0]+9),*(*(thought+0)+5));
}

What is the output of this program?

4) K   <ANS>

Goto Question no. 8

Answer of Question No. 9 -->


#include <stdio.h>
void main()
{
int I=3,*j,**k;
j=&I;
k=&j;
printf("%d%d%d",*j,**k,*(*k));
}
What is the output of the above program code?
3) 333   <ANS>

Goto Question no. 9

Answer of Question No. 10 -->


Which of the following is the correct way of declaring a float pointer:
2) float *ptr;   <ANS>

Goto Question no. 10

Answer of Question No. 11 -->


The reason for using pointer is ...
Choose the false option from the following sentences
1) Accessing arrays or string elements   <ANS>

Goto Question no. 11

Answer of Question No. 12 -->


The size of a structure can be determined by
a. size of variable name
b. size of (struct tag)

3) Both a and b   <ANS>

Goto Question no. 12

Answer of Question No. 13 -->


main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program?

1) program will not compile   <ANS>

Goto Question no. 13

Answer of Question No. 14 -->


Pushdown list means:
4) All of the above   <ANS>

Goto Question no. 14

Answer of Question No. 15 -->


What is time required to insert an element in a stack with linked implementation?

1) O(

1)   <ANS>

Goto Question no. 15

Answer of Question No. 16 -->


Which of the following is the feature of stack?
1) All operations are at one end

Goto Question no. 16

Answer of Question No. 17 -->


To create a linked list, we can allocate space and make something point to it, by writing:
struct-name *pointer-variable;
Which of the following statement will correctly allocate the space

1) pointer-variable = malloc(sizeof(*struct-name));
2) pointer-variable = malloc(sizeof(struct struct-name));
3) pointer-variable = alloc(sizeof(struct struct-name));
4) pointer-variable = alloc(sizeof(*struct-name));

Goto Question no. 17

Answer of Question No. 18 -->


What result is achieved through the following code snippet?
int initialize(NODE **circle)
{
if ((*circle = (NODE *)malloc(sizeof(NODE))) == NULL)
return 0;
(*circle)->next = NULL;
(*circle)->previous = NULL;
return 1;
}

1) The node circle is assigned to NULL


2) The size of the node circle is assigned to NULL
3) Both the pointers next and previous are assigned to NULL
4) None of these options

Goto Question no. 18

Answer of Question No. 19 -->


What would be the output of the following program?
#include <stdio.h>
main()
{
char str[]="S\065AB";
printf("\n%d", sizeof(str));
}

3) 5   <ANS>

Goto Question no. 19


Answer of Question No. 20 -->
fputs function is used to
i. write characters to a file
ii. takes 2 parameters
iii. returns a character
iv. requires a file pointer

4) only i,ii and iv are true   <ANS>

Goto Question no. 20

Answer of Question No. 21 -->


#include<stdio.h>
void main()
{
int a; printf("%d",a^a);
}

2) 0   <ANS>

Goto Question no. 21

Answer of Question No. 22 -->


Time taken for addition of element in queue is
3) O(log n)   <ANS>

Goto Question no. 22

Answer of Question No. 23 -->


To delete a dynamically allocated array named `a`, the correct statement is

1) delete a;   <ANS>

Goto Question no. 23

Answer of Question No. 24 -->


An entire structure or union variable can be assigned to another structure or union
variable if

1) The two variables have the same composition.


2) The two variables are of same type.
3) Assignment of one structure or union variable to another is not possible.
4) None of these options

Goto Question no. 24

Answer of Question No. 25 -->


What is the output of the following code?
#include<stdio.h>
void swap(int&, int&);
void main()
{
int a = 10,b=20;
swap (a++,b++);
printf("\n%d\t%d\t",a, b);
}
void swap(int& x, int& y)
{
x+=2;
y+=3;
}

4) Error   <ANS>

Goto Question no. 25

Answer of Question No. 26 -->


What will be the value of `a` after the following code is executed #define square(x) x*x a
= square(2+3)
3) 11   <ANS>

Goto Question no. 26

Answer of Question No. 27 -->


The five items: A, B, C, D and E are pushed in a stack,one after the other starting from
A. The stack is popped four times and each element is inserted in a queue. Then two
elements are deleted from the queue and pushed back on the stack. Now one item is
popped from the stack.
The popped item is.
4) D   <ANS>

Goto Question no. 27

Answer of Question No. 28 -->


What is the output of the following code? #include void main() { int a=0,b=0; a = (b =
75) + 9; printf("\n%d, %d",a, b); }
3) 84, 75   <ANS>

Goto Question no. 28

Answer of Question No. 29 -->


Object Oriented Technology`s use of _________ facilitates the reuse of the code and
architecture and its __________ feature provides systems with stability, as a small
change in requirements does not require massive changes in the system:
1) Encapsulation; inheritance
2) Inheritance; polymorphism
3) Inheritance; encapsulation
4) Polymorphism; abstraction

Goto Question no. 29

Answer of Question No. 30 -->


A recursive function would result in infinite recursion, if the following were left out:

1) Base case
2) Recursive call
3) Subtraction
4) Local variable declarations

Goto Question no. 30

Answer of Question No. 31 -->


Which of the following are class relationships?

1) is-a relationship.
2) Part-of relationship.
3) Use-a relationship.
4) All of these options.

Goto Question no. 31

Answer of Question No. 32 -->


In OOP`s, advantage of inheritance include.

1) Providing a useful conceptual framework.


2) Avoiding rewriting a code.
3) Facilitating class libraries.
4) All of these options.

Goto Question no. 32

Answer of Question No. 33 -->


What is inheritance?

1) It is same as encapsulation.
2) Aggregation of information.
3) Generalization and specialization.
4) All of these options.

Goto Question no. 33


Answer of Question No. 34 -->
Object orientated programming allows for extension of an objects function or of class
function. This ability within OOP is called ________________ .

1) extendibility
2) expansion capacity
3) virtual extension
4) scalability

Goto Question no. 34

Answer of Question No. 35 -->


UML stands for
2) Unified modeling language   <ANS>

Goto Question no. 35

Answer of Question No. 36 -->


Which of the following programming technique focuses on the algorithm.

1) Procedural language
2) Object oriented language
3) Object based language
4) Structural language

Goto Question no. 36

Answer of Question No. 37 -->


_______ provide useful conceptual framework.

1) Inheritance
2) Polymorphysm
3) Encapsulation
4) None of these options

Goto Question no. 37

Answer of Question No. 38 -->


Which of the following is true:

1) Class is an object of an object.


2) Class is meta class.
3) Class cannot have zero instances.
4) None of these options.
Goto Question no. 38

Answer of Question No. 39 -->


The design of classes in a way that hides the details of implementation from the user is
known as:

1) Encapsulation
2) Information Hiding
3) Data abstraction
4) All of these options

Goto Question no. 39

You might also like