Exercise: Declarations And Initializations

Questions for: Declarations And Initializations

By default a real number is treated as a
A:
float
B:
double
C:
long double
D:
far double
Answer: B

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.

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: A
/* Example for ceil() and floor() functions: */

#include<stdio.h>
#include<math.h>

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

    return 0;
}
// Output:
// Result : 2.000000
// Result : 2.000000
// Result : 1.000000
// Result : 1.000000
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: B

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.

Which of the following special symbol allowed in a variable name?
A:
* (asterisk)
B:
| (pipeline)
C:
- (hyphen)
D:
_ (underscore)
Answer: D

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

What are the types of linkages?
A:
Internal and External
B:
External, Internal and None
C:
External and None
D:
Internal
Answer: B
External Linkage-> means global, non-static variables and functions.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.
Ad Slot (Above Pagination)
Quiz