Question
1.
2.
3.
4.
Answer (Detailed Solution Below)
Option 4 : `register int r; int *p = &r;` / `register int r; int *p = &r;`
Advertisement
Detailed Solution
सही उत्तर `register int r; int *p = &r;` / `register int r; int *p = &r;` है।
Key Points
Helpful?
Question:
Which of the following C declarations is ILLEGAL? / निम्नलिखित में से कौन-सी C घोषणा अवैध है?
1.
`auto int x = 5;` inside a function / फंक्शन के अंदर `auto int x = 5;`
2.
`static int y;` at file scope / फ़ाइल scope पर `static int y;`
3.
`extern int z;` inside a function / फंक्शन के अंदर `extern int z;`
4.
`register int r; int *p = &r;` / `register int r; int *p = &r;`
Correct Answer: `register int r; int *p = &r;` / `register int r; int *p = &r;`
The address-of operator cannot be applied to a `register` variable — the compiler may keep it in a CPU register with no memory address, so `&r` is a compile-time error. The other three declarations are all legal. / `register` variable पर address-of operator नहीं लगाया जा सकता — कंपाइलर उसे बिना मेमोरी address वाले CPU register में रख सकता है, अतः `&r` कंपाइल-समय त्रुटि है। अन्य तीनों घोषणाएँ वैध हैं।
Downloaded from PrepSnap (prepsnap.in)