Think Dream Create Inovate

Sunday, June 5, 2011

C Programming :: Declarations and Initializations

1.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 & Explanation

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

2. What are the types of linkages?
A. Internal and External B. External, Internal and None
C. External and None D. Internal
Answer & Explanation

Answer: Option B

Explanation:

External Linkage-> means global, non-static variables and functions.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.
3.Which of the following special symbol allowed in a variable?
A. * (asterisk) B. | (pipeline)
C. - (hyphen) D. _ (underscore)
Answer & Explanation

Answer: Option D

Explanation:

Variable names in C are made up of letters (upper and lower case) and digits. The underscore character ("_") is also permitted. Names must not begin with a digit.

Examples of valid (but not very descriptive) C variable names:
=> foo
=> Bar
=> BAZ
=> foo_bar
=> _foo42
=> _
=> QuUx

No comments:

Post a Comment