C & C++ Programming Multiple Choice Questions - Set 40

1.       What would be output of the following program, if the array begins at 65486 ?
main()
{
int arr[ ] = {12, 14, 15, 23, 45};
printf(“%u%u”, arr+1, &arr+1);
}
(A) 65486, 65486
(B) 65488, 65488
(C) 65488, 65496
(D) None of the above
Answer: C
Explanation:
Array begins at address 65486 so arr+1=65488 as size of int is 2 bytes and
&arr+1=65486+10=65496 as there are 5 elements in array.
2.       Given the statement, maruti.engine.bolts=25;
which of the following is true ?
(A) Structure bolts is nested within structure engine
(B) Structure engine is nested within structure maruti
(C) Structure maruti is nested within structure engine
(D) Structure maruti nested within structure bolts
Answer: B
3.       Which amongst the following is not a keyword ?
(A) external
(B) int
(C) float
(D) double
Answer: A
4.       If a = 5 and b = 7 then the statement p = (a > b) : a ? b
(A) assigns a value 5 to p
(B) assigns a value 7 to p
(C) assigns a value 8 to p
(D) gives an error message
Answer: D
5.       The expression P >> 6 shifts all bits of P six places to right. What is the value of P >> 6 if P = 0×6db7 ?
(A) 0×1234
(B) 0×0001
(C) 0×0000
(D) 0×1B6
Answer: D

6.       The following code displays
main( )
{
int *p;
p = (int*) malloc(sizeof(int));
*p = 10;
printf(“p = %d\n”, *p);
}
(A) 10
(B) 1542 (address of p)
(C) 20
(D) None of the above
Answer: A
7.       The .............. operator is a technique to forcefully convert one data type to the others
(A) Cast
(B) Conversion
(C) Type
(D) Uniary
Answer: A
8.       ‘C’ is often called a
(A) Object oriented language
(B) High level language
(C) Assembly language
(D) Machine level language
Answer: B
9.       Which of the following is the odd one out?
(A) j = j + 1;
(B) j =+ 1;
(C) j++;
(D) j += 1;
Answer: B
Explanation:
j=+1 is odd one out as rest all means incrementing the value of variable by 1.
10.    Which of the following statements are true in c++?
(A) Classes can not have data as public members.
(B) Structures can not have functions as members.
(C) Class members are public by default.
(D) None of these.
Answer: B


Post a Comment

0 Comments