C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - Point Out Correct Statements (Q.No. 6)
6.
1 : typedef long a;
extern int a c;
2 : typedef long a;
extern a int c;
3 : typedef long a;
extern a c;
1 correct
2 correct
3 correct
1, 2, 3 are correct
Answer: Option
Explanation:

typedef long a;
extern int a c;
while compiling this statement becomes extern int long c;. This will result in to "Declaration syntax error".

typedef long a;
extern a int c;
while compiling this statement becomes extern long int c;. This will result in to "Too many types in declaration error".

typedef long a;
extern a c;
while compiling this statement becomes extern long c;. This is a valid c declaration statement. It says variable c is long data type and defined in some other file or module.

So, Option C is the correct answer.

Discussion:
14 comments Page 2 of 2.

Kiran said:   1 decade ago
Before and after type def it will not allow any data types.
but these are valid and also same lets try
1.extern int long x
2.extern long int x
3.long extern int x
4.int extern long x
(1)

Megha said:   1 decade ago
Whats wrong with long int. ?

Shibi said:   1 decade ago
Yeah jatin is correct it will be considered as a long int datatype.

JATIN said:   1 decade ago
1. typedef long a;
2. extern a int c;

In this case if we replace a in second statement with long it will not show error. And I think if we use typedef then it is literally substituted for the given name.


Post your comments here:

Your comments will be displayed after verification.