C Programming - Declarations and Initializations
- Declarations and Initializations - General Questions
- 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
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.
1 : |
|
2 : |
|
3 : |
|
C data types classification are
- Primary data types
- int
- char
- float
- double
- void
- Secondary data types (or) User-defined data type
- Array
- Pointer
- Structure
- Union
- Enum
So, clearly long int l = 2.35; is not User-defined data type.
(i.e.long int l = 2.35; is the answer.)
extern int i;
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".
1 : | extern int x; |
2 : | float square ( float x ) { ... } |
3 : | double pow(double, double); |
double pow(double, double); - is a function prototype declaration.
Therefore, 1 and 3 are declarations. 2 is definition.
#include<stdio.h>
int main()
{
extern int a;
printf("%d\n", a);
return 0;
}
int a=20;
- During declaration we tell the datatype of the Variable.
- During definition the value is initialized.