You are on page 1of 26

Faculty of Diploma Studies – 695

Department of Computer Engineering – 07


ACP MCQ Questions Bank

Multiple Choice Questions

Subject:ACP Semester:2nd
1. What is meaning of following declaration ? int arr[20];
a. Array of Size 20

b. Array of size 20 that can have integer address

c. Integer Array of size 20


d. None of these

2. What will be the output of the following program?


void main( )
{
int x [ ]= {10,20,30,40,50};
printf (“ \n %d %d %d %d “, x[4] ,3[x] ,x[2] ,1[x] ,x[0] );
}
a. Error
b. 10 20 30 40 50

c. 50 40 30 20

d. None of Above

3. In C Programming, If we need to store word "INDIA" then syntax is as below -


a. char name[6] = {"I","N","D","I","A"}

b. char name(6) = {‘I’,’N’,’D’,’I’,’A’}


c. char name[6]=’INDIA’

d. char name[6] = {‘I’,’N’,’D’,’I’,’A’}

4. What is right way to initialize array?


a. int num[6] = { 2, 4, 12, 5, 45, 5 };
b. int n{} = { 2, 4, 12, 5, 45, 5 };

c. int n{6} = { 2, 4, 12 };
d. int n(6) = { 2, 4, 12, 5, 45, 5 };
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

5. An array elements are always stored in ________ memory locations.


a. Sequential
b. Random
c. Sequential and Random

d. None of the above

6. What is the maximum number of dimensions an array in C may have?


a. 1
b. 2

c. 3

d. Theoretically no limit. The only practical limits are memory size and
compilers

7. What will be printed after execution of the following code?

void main()

int a[5]={2,4,8};

printf(“%d”,a[5]);

}
a. Garbage value

b. 8
c. 9

d. 0

8. int RollNum[30][4]; is an example of


a. 1-D Array

b. 2-D Array
c. 3-D Array

d. 4-D Array
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

9. Which type of data An array can hold?


a. Constant Value

b. Value of similar data type


c. Value of different data type

d. None of these

10. If we have declared an array int a[6], then which of the following array element is
considered as last array element ?
a. a[5]
b. a[6]
c. a[4]

d. None of Above

11. Array with last element 'n' will always have array size equal to _______.
a. n
b. n-1

c. n+1
d. n*n

12. Array is an example of _______ type memory allocation.


a. Run Time

b. Compile Time
c. Both a and b
d. None of Above

13. Array is ______ data type in C Programming language.


a. Primitive Data Type
b. Custom Data Type

c. Derived Data Type


d. None Of Above
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

14. Array index start from?


a. 1

b. -1

c. 0
d. None of Above

15. When you assign a value to an array element whose subscript exceeds the array size,
What happens?
a. Program crashes

b. Array size would automatically grow


c. Complier would report an error

d. Element will be set to 0

16. Which of the following correctly declares an array?


a. array anarray[10];

b. int anarray[10];
c. int anarray;
d. int anarray{10};

17. Which of the following will be used to accesses the 7th element stored in array?
a. array[5]

b. array[6]
c. array[7]
d. array[8]

18. If an array is declared as int a[10][10]; how many elements can it store?
a. 10
b. 20

c. 50

d. 100
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

19. Arrays are structures that hold multiple variables of the data type
a. int data type

b. char data type

c. same data type


d. different data type

20. Array is which data structure?


a. Linear
b. Non Linear

c. Complex
d. None of Above

21. Pointer variable is declared using preceding _________ sign.


a. &

b. *
c. %

d. ^

22. Address stored in the pointer variable is of type __________.


a. Integer
b. Character

c. Array
d. Floating

23. In order to fetch the address of the variable we write preceding _________ sign before
variable name.
a. ^

b. *

c. &
d. %
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

24. A pointer is
a. A keyword used to create variables

b. A variable that stores address of other variable


c. A variable that stores address of an instruction

d. None of These

25. "&" is called as ___________ in pointer concept.


a. Logical Operator

b. Address Operator
c. Conditional Operator
d. Bit-wise operator

26. What does the following declaration mean? int (*ptr)[10];


a. ptr is array of pointers to 10 integers

b. ptr is a pointer to an array of 10 integers


c. ptr is an array of 10 integers

d. ptr is an pointer to array

27. What is the output of this C code?

int main()
{
int *ptr, a = 10;
ptr = &a;
*ptr += 1;
printf("%d,%d/n", *ptr, a);
}
a. 10,10

b. 10,11
c. 11,10

d. 11,11
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

28. Which is an indirection operator among the following?


a. &

b. *
c. ->

d. .

29. What is the output of this C code?

int x = 0;
void main()
{
int *ptr = &x;
printf("%p\n", ptr);
x++;
printf("%p\n ", ptr);
}
a. Same address
b. Different address

c. Compile time error


d. Varies

30. What is the output of this C code?

void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **m);
}
a. 5 5 5
b. 5 5 junk value

c. 5 junk value
d. Run time error
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

31. Which of the following option is the correct way of declaring a float pointer:
a. float ptr

b. *float ptr
c. float *ptr

d. None of Above

32. What will be the output of the following program?


void main( )
{
char *msg = "hi" ;
printf( msg );
getch();

}
a. h

b. hi
c. garbage value

d. Error

33. What will be the output of the following program?


void main( )
{
char *str = "%s" ;
printf(str, “CE”);
getch();

}
a. %s

b. CE
c. Error
d. No output

34. Give meaning of: char *f

a. f is a pointer to integer

b. f is a pointer to float

c. f is a pointer to char
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

d. None of Above

35. Wild pointer in C


a if pointer has not defined properly
b. if pointer pointing to more than one variable

c. if pointer has not been initialized


d. None of Above

36. What is NULL pointer?


a. Denotes pointer to 0

b. Denotes integer pointer to 0


c. Denotes NULL pointer to integer 0

a. None of Above

37. What will be the output of the following program?


void main( )
{
char a[] = "Hello World" ;
char *p=&a;
printf(“\n%d%d%d%d”,sizeof(a),sizeof(p),strlen(a),strlen(p));
getch();

}
a. 11 11 10 10

b. 12 12 11 11
c. 10 10 10 10

d. 12 2 11 11

38. Size of void pointer in 32 bit system


a. 1 byte

b. 4 byte
c. 8 byte
d. 2 byte
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

39. Pointer is a
a. Basic Data type

b. Derived data type


c. Used defined data type

d. Primitive data type

40. Which of the following is the proper keyword to allocate memory in C?


a. new

b. malloc
c. create
d. value

41. function is a
a. Basic Data type

b. Derived data type


c. Used defined data type

d. Primitive data type

42. Which of the following function calculates the square of 'X' in C?


a. sqr(X)
b. pow(2,X)

c. power(2,X)

d. pow(X,2)

43. What is function?


a. A block of code that performs a specific task which has a name and is reusable

b. It is a fundamental modular unit which is designed to perform a specific task


c. A block of statements that perform some specific task

d. All of Above
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

44. Every function in C are followed by?


a. Parameter

b. Parenthesis
c. Square Braces

d. None Of Above

45. Which functions are used for only single character input/output ?
a. getchar( ) and putchar( )
b. scanf( ) and putchar( )

c. scanf( ) and printf( )


d. getchar( ) and printf( )

46. Which is a correct format for declaration of function?


a. return-type (argument type)function-name

b. return-type function-name(argument type)


c. Function-name return-type(argument type)

d. None of Above

47. The value obtained in the function is given back to main by using ________ keyword?
a. static
b. new

c. value

d. return

48. Recursion is a process in which a function calls


a. Main() function

b. Itself
c. Another function

d. None of the above


Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

49. Which function is used for converting string into lowercase


a. strlower

b. strproper

c. strlwr
d. strupr

50. The function scanf() returns


a. 0
b. ASCII value of the input read

c. The number of successful read input values


d. The actual values read for each argument

51. If n=fmod(38,17) then n=?


a. 3

b. 2.23
c. 2

d. 4

52. character array always ends with


a. Null(‘\0’) character
b. Question marks

c. Full stop(.)
d. None of Above

53. Which header file is to be included for using string functions.


a. str.h

b. string.h
c. stdio.h

d. conio.h
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

54. What is output of below code?

void main()

char name[]="Cppbuz";

int len;

int size;

len = strlen(name);

size = sizeof(name);

printf("%d,%d",len,size);

}
a. 0,0
b. 6,6

c. 7,7

d. 6,7

55. Every C Program must have one function called?


a. for()

b. scanf( )

c. main()
d. printf()

56. if n=ceil(7.1) then n=?


a. 7.1
b. 9

c. 8
d. 7
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

57. The recursive functions are executed in a ...........


a. First In First Out order

b. Parallel order

c. Last In First Out order


d. Iterative order

58. By default the function returns


a. Float value
b. Char value

c. Integer value
d. None of Above

59. In _____________ formal argument change actual argument


a. Call by Value

b. Call by Address
c. Both a and b

d. None of Above

60. Any C program


a. Need not contain any function

b. Must contain at least one function


c. Needs input data.
d. None of the above.

61. If the two strings are identical the strcmp( ) function returns.
a. 0
b. -1
c. 1

d. None of Above
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

62. C preprocessor
a. Takes care of conditional compilation

b. Takes care of include files


c. Takes care of macros

d. All of the above

63. A preprocessor directive


a. need not start on a new line

b. has # as the first character


c. need not start on the first column
d. All of the above

64. What will be the output of the following program?

65. #include<stdio.h>

#define square(x) x*x

void main()

int i;

i = 64/(square(4));

printf("%d", i);

}
a. 16

b. 4
c. 64

d. None of Above
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

66. The pre-processor directives must be preceded by which symbol?


a. @

b. &

c. #
d. *

67. The pre-processor directives are always initialized at the


a. Run time
b. Beginning of the program

c. Compile time
d. None of Above

68. The pre-processor passes the source code to the C__________.


a. Compiler
b. Interpreter
c. Assembler

d. None of Above

69. #include is called


a. Inclusion directive
b. File inclusion directive

c. Preprocessor directive
d. None of Above

70. How will you print \n on the screen?


a. echo "\\n";

b. printf('\n');
c. printf("\n");

d. printf("\\n");
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

71. Symbolic constants can be defined using


a. # define
b. Symbols
c. Const

d. None of Above

72. The meaning of keyword VOID before function name means


a. Function should return any value
b. No arguments are passed

c. Function should not return any value


d. None of the above

73. Which of the following are correct pre-processor directives in C?

1.#undef

2.#if

3.#elif

4.#error
a. 1,2

b. 2,4

c. 1,2,3,4
d. 1,2,3

74. Which of the following is a collection of different data types?


a. String
b. Array

c. Files

d. Structure
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

75. How many bytes are occupied by the following structure?

struct employee

int emp_id;

double ph_no;

char name [100];

};
a. 100

b. 106
c. 108

d. 110

76. For accessing a structure elements using a pointer, you must use
a. Pointer Operator (& Operator)
b. Dot Operator (. Operator)

c. Pointer Operator (* Operator)

d. Arrow Operator (->)

77. Most appropriate statement to describe Union is


a. Union are like Structures

b. Union contain members of different data types which share the same
storage area in memory
c. Union is less frequently used in a program
d. Union are used for set operations

78. Which of the following have similar syntax?


a. Structure and union
b. Union and array
c. Structure and pointer
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

d. Array and pointer

79. Which operator is used for connecting a structure name to its member name?
a. * operator
b. <- operator

c. . (dot) operator
d. & operator

80. How many bytes are occupied by the following union?

union student

int n;

char name [20];

};
a. 18
b. 20

c. 22
d. 24

81. Which keyword is used to define the user defined data types?
a. def

b. type

c. typedef
d. union

82. What is important difference between structure & union?


a. Structure is faster
b. Union takes less memory

c. Union is faster

d. Both b and c
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

83. Can we declare function inside structure of C Programming?


a. yes

b. no
c. Depends on Compiler

d. Yes but run time error

84. For binary files, a ___ must be appended to the mode string.
a. Nothing

b. “b”
c. “binary”
d. “01”

85. If there is any error while opening a file, fopen will return?
a. NULL
b. EOF
c. Depends on compiler

d. Nothing

86. What are the first and second arguments of fopen?


a. A character string containing the name of the user & the second argument is
the mode

b. A character string containing file pointer & the second argument is the mode

c. A character string containing the name of the file & the second argument
is the mode
d. All of above

87. What is FILE reserved word?


a. It is a type name defined in stdio.h
b. Pointer to the structure defined in stdio.h
c. One of the basic data types in c

d. A structure tag declared in stdio.h


Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

88. What is output of below program?

int main()

int _ = 10;

int __ = 20;

int ___ = _ + __;

printf("__%d",___);

return 0;

}
a. Compilation Error

b. Runtime Error
c. __0

d. __30

89. The contents of a file will be lost if it is opened in


a. ‘a’ mode

b. ‘w’ mode
c. ‘w+’ mode
d. ‘a+’ mode

90. Which type of files can’t be opened using fopen()?


a. .txt

b. .bin
c. .c

d. None of the mentioned


Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

91. What is the meant by ‘a’ in the following operation? fp = fopen(“Random.txt”, “a”);
a. Attach

b. Append
c. Add

d. Apprehend

92. feof() indicates


a. Error in a file

b. End of file
c. Move to the beginning of file
d. Move to desired position in file

93. The function fopen (“filename”, “r”) return


a. Nothing

b. Value 0 or 1 depending whether file can be opened or not


c. A pointer to a new file after creating it

d. A pointer to FILE filename, if it exists

94. Which function will return the current file position for stream?
a. fseek()
b. fsetpos()

c. fgetpos()

d. ftell()

95. The fseek() function


a. Needs 3 arguments

b. Change file pointer position


c. is meant for checking whether a given file exists or not.

d. Both a and b
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

96. The value of EOF is


a. -1
b. 0
c. 1

d. 10

97. In the following code what is 'P'?

typedef char *charp;

const charp P;
a. P is a constant
b. P is character type

c. P is a character constant
d. None of Above

98. Purpose of fclose()


a. open a file

b. close a file
c. write a file

d. read a file

99. Purpose of fscanf()


a. reads a set of data from a file
b. reads a integer from a file

c. writes a set of data to a file


d. writes a integer to a file

100. Purpose of fseek()


a. gives current position in the file

b. set the position to the beginning point


c. open a existing file

d. set the position to desire point


Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

101. The number of bytes required for enumerated data type in memory is
a. 1 byte

b. 2 byte
c. 3 byte

d. 4 byte

102. What is the output of the following program?

int main()

if(-5);

printf("C");

else

printf("C++");

return 0;

}
a. C
b. C++

c. C C++

d. Compile Error

103. What is the similarity between a structure, union and enumeration?


a. All of them let you define new structures

b. All of them let you define new values


c. All of them let you define new pointers

d. All of them let you define new data types


Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

104. What will be the value of k?

int i=3, *j, k;

j = &i;

k=i**j*i+*j;
a. 3
b. 27

c. 30
d. 9

105. What will be the value of k?

a=5, b=10;

p1=&b, p2=&a;

c= *p1-*p2;
a. -5
b. -10

c. 10

d. 5

106. What is meaning of below lines?

void sum (int, int);


a. it will produce compilation error
b. sum is function which takes int arguments

c. sum is a function which takes two int arguments and returns void
d. No comment
Faculty of Diploma Studies – 695
Department of Computer Engineering – 07
ACP MCQ Questions Bank

107. What is the output of following code

printf(“%d”,i);
a. 105
b. I

c. 73
d. i

108. W hat do the 'c' and 'v' in argv stands for?


a. 'c' means argument control 'v' means argument vector

b. 'c' means argument count 'v' means argument vertex

c. 'c' means argument count 'v' means argument vector


d. 'c' means argument configuration 'v' means argument visibility

109. In which stage the following code

#include<stdio.h>

gets replaced by the contents of the file stdio.h


a. During editing
b. During linking

c. During execution

d. During preprocessing

110. W hat is output of following code

int a = 4, b = 6;

printf (" %d ", a != b) ;


a. Output error message

b. 0

c. 1
d. None of above

You might also like