Programming and Problem Solving MCQ For ASI
1. C constants can be divided into ------------ categories ?
a) 3
b) 6
c) 2
d) 4
2. Who invented the C programming ?
a) James Gosling
b) Dennis Ritche
c) Bjarne Stroustrup's
d) Tim Berners Lee
3. C is ----------- language .
a) Low Level
b) Middle Level
c) Machine Level
d) All of above
4. Where does C language get invented ?
a) Rithe's Lab
b) AT & T Bell Labs
c) Under Oak Tree
d) Fringe Labs
5. Which symbol terminates a C statement ?
a) .
b) ,
c) ;
d) }
6. How to comment in C language ?
a) // comment
b) /* comment */
c) <---comment--->
d) A & B
7. Which is not a character of C ?
a) $
b) !
c) ^
d) ~
8. Identify the scalar data type in C
a) Union
b) Function
c) Double
d) Array
9. How many tokens are in the following if(age==21)
a) 4
b) 5
c) 6
d) 7
10. Which is an invalid variable name ?
a) integer
b) Xx
c) Net total
11. Who is the father of C language ?
a) Bjarne Stroustrup
b) Dennis Ritchie
c) James A. Gosling
d) Dr. E.F. Codd
12. C Language developed at -------------- ?
a) AT & T's Bell Laboratories of USA in 1972 .
b) AT & T's Bell Laboratories of USA in 1970 .
c) Sun Microsystems in 1973
d) Cambridge university in 1972
13. For 16 bit compiler allowable range for integer constant is ------------
a) -3.4e38 to 3.4e38
b) -32767 to 32768
c) -32768 to 32767
d) -32668 to 32667
14. C programs are converted into machine language with the help of -----------
a) An Editor
b) A compiler
c) An Operating system
d) None of the above
15. A C variable cannot start with
a) An alphabet
b) A number
c) A special symbol other than underscore
d) Both (b) and (c)
16. Which of the following is allowed in a C arithmetic instruction
a) []
b) {}
c) ()
d) None of the above
17. Which of the following shows the correct hierarchy of arithmetic operations in C
a) / + * -
b) * - / +
c) + - / *
d) * / + -
18. What is an array ?
a) An array is a collection of variables that are of the dissimilar data type .
b) An array is a collection of variables that are of the same data type .
c) An array is not a collection of variables that are of the same data type
d) None of the above
19. What is right way to initialization 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 } ;
20. An array elements always stored in ------------ memory .
a) Sequential
b) Random
c) Sequential and Random
21. What is the right way to access value of structure variable book { price , page } ?
a) printf(" %d%d " , book.price , book.page };
b) printf( " %d%d " , price.book , page.book ) ;
c) printf( " %d%d " , price::book , page::book ) ;
d) printf( " %d%d " , price->book , page->book ) ;
22. Perror() function used to ?
a) Work same as printf()
b) Prints the error message specified by the compiler
c) Prints the garbage value assigned by the compiler
d) None of the above
23. Bitwise operators can operate upon ?
a) Double and chars
b) Floats and doubles
c) ints and floats
d) ints and chars
24. What is C Tokens ?
a) The smallest individual units of c program
b) The basic element recognized by the compiler
c) The largest individual units of program
d) A & B Both
25. What is Keywords ?
a) Keywords have some predefine meanings and these meanings can be changed
b) Keywords have some unknown meanings and these meanings cannot be changed
c) Keywords have some predefine meanings and these meanings cannot be changed
d) None of above
26. What is constant ?
a) Constant have fixed values that do not change during the execution of a program
b) Constants have fixed values that change during the execution of a program
c) Constants have unknown values that may be change during the execution of a program
d) None of above
27. Which is the right way to declare constant in C ?
a) int constant var = 10;
b) int const var = 10;
c) const int var = 10;
d) B & C Both
28. Which operators are known as Ternary Operator ?
a) ::, ?
b) ?,:
c) ?,;;
d) None of above
29. In switch statement , each case instance value must be ------------ ?
a) Constant
b) Variable
c) Special symbol
d) None of above
30. What is the work of break keyword ?
a) Halt execution of program
b) Restart execution of program
c) Exit from loop or switch statement
31. What is function ?
a) Function is a block of statements that perform some specific task .
b) Function is the fundamental modular unit . A function is usually designed to perform a specific task
c) Function is a block of code that performs a specific task . It has a name and it is reusable
d) All of above
32. Which one of the following sentences is true ?
a) The body of a while loop is executed at least once .
b) The body of a do ... while loop is executed at least once .
c) The body of a do ... while loop is executed zero or more times .
d) A for loop can never be used in place of a while loop .
33. A binary tree wit 27 nodes has ------- null branches .
a) 54
b) 27
c) 26
d) None of the above
34. Which one of the following is not a linear data structure ?
a) Array
b) Binary tree
c) Queue
d) Stack
35. Recursive functions are executed in a ?
a) First In First Out Order
b) Load Balancing
c) Parallel Fashion
d) Last In First Out Order
36. Queue is a ------- list .
a) LIFO
b) LILO
c) FILO
d) FIFO
37. The statement printf ( " %d" , 10 ? 0 ? 5 : 1 : 12 ) ; will print ?
a) 10
b) 0
c) 12
d) 1
38. To represent hierarchical relationship between elements , which data structure is suitable ?
a) Priority
b) Tree
c) Dqueue
d) All of the above
39. Which of the following data structure is linear type ?
a) Strings
b) Queue
c) Lists
d) All of above
40. The statement printf("%c",100); will print ?
a) Prints 100
b) print garbage
c) Prints ASCII equivalent of 100
41. The ---------- memory allocation function modifies the previous allocated space .
a) calloc
b) free
c) malloc
d) realloc
42. Number of binary trees formed with 5 nodes are
a) 30
b) 36
c) 108
d) 42
43. The " C " language is
a) Context free language
b) Context sensitive language
c) Regular language
d) None of above
44. The worst case time complexity of AVL tree is better in comparison to binary search tree for
a) Search and Insert Operations
b) Search and Delete Operations
c) Insert and Delete Operations
d) Search , Insert and Delete Operations
45. In which tree for every node the height of its left subtree and right subtree differ almost by one ?
a) Binary search tree
b) AVL tree
c) Threaded Binary Tree
d) Complete Binary Tree
46. C is --------- language ?
a) Low level
b) High level
c) Assembly level
d) Machine level
47. The default parameter passing mechanism is called as
a) Call by value
b) Call by references
c) Call by address
d) Call by name
48. What is Dequeue ?
a) Elements can be added from front
b) Elements can be added to or removed from either the front or rear
c) Elements can be added from near
d) None of the above
49. In which linked list last node address is null ?
a) Doubly linked list
b) Circular list
c) Singly linked list
d) None of above
50. Which is the correct syntax to declare constant pointer ?
a) int *const constPtr;
b) *int constant constPtr;
c) const int *constPtr;
51. What will be the output of the following arithmetic expression 5+3*2%10-8*6
a) -37
b) -42
c) -32
d) -28
52. What will be the output of the following statement ? int a = 10; printf("%d &i",a,10) ;
a) error
b) 10
c) 10 10
d) None of these
53. What will be the output of the following statement ? printf("%X%x%ci%x",11,10,'s',12);
a) Error
b) basc
c) Bas94c
d) None of these
54. What will be the output of the following statements ?
int a = 4 , b = 7 , c ; c=a ==b ; printf("%i",c);
a) 0
b) error
c) 1
d) Garbage value
55. What will be the output value of the following statements ?
int a = 5 , b= 2 , c = 10 , i = a>b
void main ()
{
printf("hello");
main();
}
a) 1
b) 2
c) infinite number of times
d) None of these
56. What will be the output if you will compile and execute the following c code ?
struct marks
{
int p:3;
int c:3;
int m:2;
};
void main () {
struct marks s = { 2, -6, 5 } ;
printf ( " %d%d%d ", s.p,s.c,s.m);
}
a) 2 -6 5
b) 2 -6 1
c) 2 2 1
d) Compile error
e) None of these
57. What will be the output of the following statements ?
int x[4] = { 1, 2, 3 } ;
printf("%d %d %D " , x[3], x[2], x[1]);
a) 03%D
b) 000
c) 032
d) 321
58. What will be the output of the following statement ?
printf( 3 + " goodbye " ) ;
a) goodbye
b) odbye
c) bye
d) dbye
59. What will be the output of the following statements ?
long int a = scanf("%1d%1d",&a, &a ) ;
printf("%1d",a);
a) error
b) Garbage value
c) 0
d) 2
60. What will be the output of the following program ?
#include
void main ()
{
int a = 2;
switch(a)
{
case 1: printf("goodbye");break;
case2: continue;
case3: printf("bye");
}}
a) error
b) goodbye
c) bye
61. What will be the output of the following statements ?
int i = 1 ,
j;
j=i-2;
printf("%d",j);
a) Error
b) 2
c) 3
d) -3
62. What will be the output of the following program ?
#include
{
int x,y = 10;
x=y*NULL ;
printf("%d",x);
}
a) Error
b) 0
c) 10
d) Garbage value
63. What will be the output of the following statements ?
char x [] = " hello hi " ;
printf("%d%d",sizeof(*x),sizeof(x));
a) 88
b) 18
c) 29
d) 19
64. What will be the output of the following statements ?
int a=5 , b=6, c=9, d;
d=(ac?1:2):(c>b?6:8));
printf("%d",d);
a) 1
b) 2
c) 6
d) Error
65. What will be the output of the following statements ?
int i = 3;
printf("%d%d",i,i++);
a) 34
b) 43
c) 44
d) 33
66. What will be the output of the following program ?
#include
void main()
{
int a=36,b=9;
printf("%d",a>>a/b-2);
}
a) 9
b) 7
c) 5
d) None of these
67. 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) 11
b) 7
c) 5
d) 9
68. void main ()
{
int a = 10, b=20;
char x=1, y=0;
if(a,b,x,y)
{
printf("EXAM");
}}
What is the output ?
a) XAM is printed
b) exam is printed
c) Compiler error
d) Nothing is printed
69. What is the output of the following code ?
#include
void main ()
{
int s=0;
while(s++<10)>
#define a 10
main ()
printf("%d..",a);
foo();
printf("%d",a);
}
void foo ()
{
#undef a
#define a 50
}
a) 10..10
b) 10..50
c) Error
d) 0
70. main()
{
struct
{
int i;
}
xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
What is the output of this program ?
a) Program will not compile
b) 10
c) god only knows
71. What will happen if in a C program you assign a value to an array element whose subscript exceeds the size of array ?
a) The element will be set to 0
b) The compiler would report an error
c) The program may crash if some important data gets overwritten
d) The array size would appropriately grow
72. What would be the output of the following program ?
#include
main()
{
printf("\n%d",sizeof(str));
}
a) 7
b) 6
c) 5
d) Error
73. What will be the value of 'a' after the following code is executed
#define square(x) x*x
a = square(2+3)
a) 25
b) 13
c) 11
d) 10
74. #include
void main ()
{
int x = 0 ;
static int y = 0 ;
x++ ; y++ ;
printf("%d__%d\n",x,y);
}
int main()
func();
func();
return();
}
What will the code above print when it is executed ?
a) 1 _ 1
1_ 1
b) 1 _ 1
2 _ 1
c) 1 _ 1
2 _ 2
d) 1 _ 1
1 _ 2
75. long factorial ( long x )
{
????
return x * factorial ( x - 1 ) ;
}
With what do you replace the ???? to make the function shown above return the correct answer ?
a) if ( x ==0 ) return 0;
b) return 1 ;
c) if ( x >=2 ) return 2;
d) if ( x<=1) return 1 ;
76. int y[4] = { 6,7,8,9 } ;
int * ptr = y + 2 ;
printf("%d\n",ptr [ 1 ] );
What is printed when the sample code above is executed ?
a) 6
b) 7
c) 8
d) 9
77. int i = 4;
switch (i)
{
default: ;
case 3:
i += 5 ;
if ( i == 8 )
{
i ++ ;
if(i == 9 ) break ;
i*=2;
}
i-=4;
break;
case 8:
i+= 5 ;
break;
}
printf("i = %d\n" , i );
What will the output of the sample code above be ?
a) i = 5
b) i = 8
c) i = 9
d) i = 10
78. What will be output if you will compile and execute the following c code ?
void main ()
{
if(printf("cquestionbank"))
printf(" I know C " );
else
printf(" I know c++ " );
}
a) I know c
b) I know c++
c) CquestionbankI know c
d) cquestionbankI know c++
e) Compile error
79. What will be the output if you will compile and execute the following c code ?
#define call(x) #x
void main() {
printf("%s",call(c/c++));
}
a) c
b) c++
c) #C/C++
d) c/c++
e) Compile error
80. What will be the output if you will compile and execute the following code ?
#define message " union is \ power of c "
void main ()
{
clrscr();
printf("%s",message);
getch();
}
a) Compile error
b) union is power of c
c) union is Power of c
Tags - ASI questions discussion , Preparations for ASI communication , Covered MP UP ASI questions , ASI police question paper , asi question paper 2019 , UP police asi previous year questions paper pdf covered , asi questions paper 2020 , asi exam paper pdf covered questions , Technical questions of computer part for competitive exam , Competitive exams technical computer part for asi exam of UP , MP , Odisha etc , Computer questions for ASI communication Odisha Police , Odisha Police questions bank computer part , Online text sub inspector , computer text free , computer text mock online , ASI major chapter covered
0 Comments