Which line only declares a variable, without defining it?
extern without an initializer announces that count is defined elsewhere; no storage is created. The other lines all create the variable.
Declarations and Initializations · Exercise 1 of 4
Twelve multiple-choice questions on declaration vs definition, extern and prototypes, linkage, identifier rules, literal types, initializers, volatile and C23. Pick an option to check your answer instantly.
Which line only declares a variable, without defining it?
extern without an initializer announces that count is defined elsewhere; no storage is created. The other lines all create the variable.
Is there any difference between extern int fun(); and int fun();?
Unless declared static, a function has external linkage, so extern on a function declaration is redundant. (In C23 both also mean "takes no parameters".)
By default, a real number constant such as 2.5 is treated as a…
Floating constants without a suffix have type double. Add f for float or L for long double.
What kinds of linkage can an identifier have in C?
External: one entity shared across files (globals, functions). Internal: one entity per file (static at file scope). None: every declaration is a separate entity (locals, parameters).
Which special symbol may appear in a variable name?
Standard C identifiers consist of letters, digits and the underscore, not starting with a digit. Some compilers accept $ as an extension, but it is not portable.
When do we need to give a function's prototype?
The compiler must know a function's type before a call. If the definition appears earlier in the same file it serves as the declaration; otherwise a prototype (usually from a header) is required.
Which of the following is not a user-defined data type?
long int is a built-in type. Structures, unions and enumerations are types the programmer defines.
Which expression gives the remainder after dividing 3.14 by 2.1?
% is only defined for integers. fmod() from <math.h> returns the floating-point remainder: 1.04.
Which call turns 1.66 into 2.0?
ceil() rounds up to the next integer value (2.0). floor(), trunc() and a cast to int all give 1. round(1.66) would also give 2.0.
After int a[5] = {1}; inside a function, what is a[3]?
Once an aggregate has an initializer, every element not explicitly initialised is set to zero – also for local arrays.
Timed online tests with instant scores and explanations.