Wednesday, 29 July 2015

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

1.       If an integer occupies 4 bytes and a character occupies 1 bytes of memory, each element of the following structure would occupy how many bytes ?
struct name
{
int age;
char name [20];
}
(A) 5       (B) 24
(C) 21     (D) 22
Answer: B
2.       If an array is used as function argument, the array is passed
(A) by value
(B) by reference
(C) by name
(D) the array cannot be used as a function argument
Answer: B
3.       To access a structure element using a pointer, ............... operator is used
(A) dot (.)           (B) pointer (&)
(C) pointer (*)    (D) arrow (→)
Answer: D
4.       The library function sqrt( ) operates on a double precision argument. If, i is an integer variable, which one of the following calls would correctly compute sqrt(i) ?
(A) sqrt((double)i)
(B) (double) sqrt(i)
(C) (double) (sqrt(i))
(D) sqrt(i)
Answer: A
5.       What will happen if the following loop is executed ?
int num = 0;
do
{
--num;
printf(“%d”, num);
num++;
}while (num >= 0);
}
(A) The loop will run infinite number of times
(B) The program will not enter the loop
(C) There will be a compilation error
(D) There will be runtime error
Answer: C

6.       The break statement causes an exit
(A) Only from the innermost loop
(B) Only from the innermost switch
(C) From the innermost loop or switch
(D) From the program.
Answer: C
7.       It is necessary to declare the type of function in the calling program if
(A) Function returns an integer
(B) Function returns a non-integer value
(C) Function is not defined in the same file
(D) Function is called number of times
Answer: B
8.       The function fprintf is used in a program
(A) When too many printf calls have been already used in the program
(B) In place of printf, since printf uses more memory
(C) When the output is to be printed on to a file
(D) When the type of variables to be printed are not known before
Answer: C
9.       The following statement displays
float x = 2000.53;
printf (“%e”, x);
(A) 2.00053e+04
(B) 2.00053e+03
(C) 2.00053+e04
(D) 2.0005e+03
Answer: B
10.    The output of the following is
int a = 75;
printf (“%d%%”, a);
(A) 75                 (B) 75%%
(C) 75%             (D) None of the above
Answer: D


0 comments:

Post a Comment

UGC NET Computer Science

Computer GK App