C Programming : Declarations and Initializations – General Questions

0
325
c-programming-declarations-and-initializations-general-questions
c-programming-declarations-and-initializations-general-questions

C Programming: Declarations and Initializations – General Questions

  • Declarations and Initializations – General Questi
  • Declarations and Initializations – Find Output of Program
  • Declarations and Initializations – Point Out Errors
  • Declarations and Initializations – Point Out Correct Statements
  • Declarations and Initializations – True / False Questions
  • Declarations and Initializations – Yes / No Questions

General Questions

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. The remainder cannot be obtained in the 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.
2. What are the types of linkages?
A. Internal and External
B. External, Internal and None
C. External and None
D. Internal
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 name?
A. * (asterisk)
B. | (pipeline)
C. – (hyphen)
D. _ (underscore)
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.

 

4. Is there any difference between the 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 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. round to(1.66)
Answer: Option