Computer Programming Mcq with Answers
1. Can you combine the following two statements into one?
char *p
p = (char*) malloc(100);
-
char p = *malloc(100)
char p = (char) malloc(100)
char p = (char) malloc(100)
2. B. Constants have fixed values that change during the execution
-
of a program
constants have unknown values that may be change during the execution
of a program
3. If a=14, b=4 then a/b =
4. In the following code, the P2 is Integer Pointer or Integer?
typederf int*ptr;
ptr pl, p2;
-
Integer
Integer pointer
Error in declaration
5. Can you combine the following two statements into one?
char *p;
p = (char)malloc(100);
-
char p =*malloc(100)
char p = (char) malloc(100)
char p = (char)malloc(100)
6. If a=14, b=4 then a%b =
7. The typedef statement is used for -
-
declaring user defined data types
declaring variant variables
for type casting of variables
8. A bit field is a set of adjacent bits whose size can be from _________ bits in length
-
1 to 8
1 to 12
1 to 14
9. A multidimensional array can be expressed in terms of
-
array of pointers rather than as pointers to a group of a contiguous array
array without the group of a contiguous array
data type arrays
10.The member variables of structure are accessed by using -
-
dot (.) operator
arrow (→) operator
asterisk (*) operator
11. The precedence of member operator is _________ than all arithmatic and relational operator
-
lower
higher
equal
12. If you want to exchange two rows in a two-dimensional array, the fastest way is to:
-
Exchange the elements of the 2rows
Exchange the address of each element in the two rows
Silence the address of the rows in an array of the pointer and exchange the pointer
13. Identify the most appropriate sentence to describe union -
-
unions contain members of different data types witch share the same storage area in memory
unions are like structures
unions are less frequency used in the program
14. Automatic variable also referred to as
-
Internal variable
Global variable
Local variable
15. The union holds
-
one object at a time
multiple objects
both (a) and (b)
16. The …… variable is not destroyed on exit from the function; instead its value is presented and becomes available again. When the function is next called. These variables are declared as …….
-
extern, localvariable
Static, global variable
Static, local variable
17. For a method to be an interface between the outside world and a class , it has to be declared
-
private
public
external
18. Bit fields are used only with
-
unsigned int data type
float data type
char data type
19. 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?
20. void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf(“EXAM”);
}
}
What is the output?
-
XAM is printed
exam is printed
Compiler Error
21. The number of bytes required for enumerated data type in memory are -
-
2 bytes
4 bytes
1 byte
22. What is the similarity between a structure, union and enumeration?
-
All of them let you define new values
All of them let you define new data types
All of them let you define new pointers
23. What will be output if you will compile and execute the following c code?
#define message “union is
power of c”
void main(){
clrscr();
printf(“%s”,message);
getch();
}
-
union is power of c
union ispower of c
union is
24. Which escape character can be used to beep from speaker in C?
-
\a
\b
\m
25. Character constants should be enclosed between ___
-
Single quotes
Double quotes
Both a and
26. String constants should be enclosed between ___
-
Single quotes
Double quotes
Both a and b
27. Which of the following is invalid?
-
‘’
““
‘a’
28. The variables declared in a structure definition are called its
-
group variables
merged variables
member variables
29. #define' preprocessor statement can be used for defining -
-
macro
function
symbolic constants only
30. The _______ chars have values from -128 to 127.
-
signed
unsigned
long
Post a Comment
0 Comments