Friday, February 11, 2011

APTITUDE Q&A




QUESTIONS WITH ANSWERS
1.Can you write 31 using only digit 3 five times?
solution:
(3^3)+3+(3/3)=31

2.An accurate clock shows 8 o'clock in the morning. Through how may degrees will the hour hand rotate when the clock shows 2 o'clock in the afternoon?

A. 144ºB. 150º
C. 168ºD. 180º

Answer: Option D

Explanation:

Angle traced by the hour hand in 6 hours = 360 x 6 º = 180º.

12
3.

Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?

A. rem = 3.14 % 2.1;
B. rem = modf(3.14, 2.1);
C. rem = fmod(3.14, 2.1);
D. Remainder cannot be obtain in floating point division.

Answer: Option C

Explanation:

fmod(x,y) - Calculates x modulo y, the remainder of x/y.
This function is the same as the modulus operator. But fmod() performs floating point divisions.

Example:


#include
#include

int main ()
{
printf ("fmod of 3.14/2.1 is %lf\n", fmod (3.14,2.1) );
return 0;
}

Output:
fmod of 3.14/2.1 is 1.040000

4.

Is there any difference between following declarations?

1 : extern int fun();
2 : int fun();

A. Both are identical
B. No difference, except extern int fun(); is probably in another file
C. int fun(); is overrided with extern int fun();
D. None of these

Answer: Option B

Explanation:

extern int fun(); declaration in C is to indicate the existence of a global function and it is defined externally to the current module or in another file.

int fun(); declaration in C is to indicate the existence of a function inside the current module or in the same file.

5.

How would you round off a value from 1.66 to 2.0?

A. ceil(1.66)B. floor(1.66)
C. roundup(1.66)D. roundto(1.66)

Answer: Option A

Explanation:

/* Example for ceil() and floor() functions: */

#include
#include

int main()
{
printf("\n Result : %f" , ceil(1.66) );

printf("\n Result : %f" , floor(1.66) );

return 0;
}

// Output: Result : 2.000000
// Output: Result : 1.000000
6.

The keyword used to transfer control from a function back to the calling function is

A. switchB. goto
C. go backD. return

Answer: Option D

Explanation:

The keyword return is used to transfer control from a function back to the calling function.

Example:


#include
int add(int, int); /* Function prototype */

int main()
{
int a = 4, b = 3, c;
c = add(a, b);
printf("c = %d\n", c);
return 0;
}
int add(int a, int b)
{
/* returns the value and control back to main() function */
return (a+b);
}

Output:
c = 7


No comments:

Post a Comment