1. | When we mention the prototype of a function? |
|||||||
Answer: Option B Explanation:
A function prototype in C or C++ is a declaration of a function that omits the function body but does specify the function's name, argument types and return type. While a function definition specifies what a function does, a function prototype can be thought of as specifying its interface. |
2. | In the following program where is the variable a getting defined and where it is getting declared?
|
|||||||
Answer: Option A Explanation: - During declaration we tell the datatype of the Variable. - During definition the value is initialized. |
3. | Identify which of the following are declarations 1 :extern int x;2 :float square ( float x ) { ... }3 :double pow(double, double); |
|||||||
Answer: Option C Explanation: extern int x; - is an external variable declaration. |
4. | Is the following statement a declaration or definition? extern int i; |
|||||||
Answer: Option A Explanation: Declaring is the way a programmer tells the compiler to expect a particular type, be it a variable, class/struct/union type, a function type (prototype) or a particular object instance. (ie. extern int i) Declaration never reserves any space for the variable or instance in the program's memory; it simply a "hint" to the compiler that a use of the variable or instance is expected in the program. This hinting is technically called "forward reference". |
5. | Which of the following is not user defined data type? 1 :
2 :
3 :
|
|||||||
Answer: Option B Explanation: C data types classification are
So, clearly long int l = 2.35; is not User-defined data type. |
6. | By default a real number is treated as a |
|||||||
Answer: Option B Explanation: In computing, 'real number' often refers to non-complex floating-point numbers. It include both rational numbers, such as 42 and 3/4, and irrational numbers such as pi = 3.14159265... When the accuracy of the floating point number is insufficient, we can use the double to define the number. The double is same as float but with longer precision and takes double space (8 bytes) than float. To extend the precision further we can use long double which occupies 10 bytes of memory space. |
7. | How would you round off a value from 1.66 to 2.0? |
|||||||
Answer: Option A Explanation:
|
8. | Is there any difference between following declarations?
|
|||||||
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. |