C Programming Questions and Answers – Register Variables – 2

«
»

This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Register Variables – 2”.

Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.

advertisement

1. When compiler accepts the request to use the variable as a register?
a) It is stored in CPU
b) It is stored in cache memory
c) It is stored in main memory
d) It is stored in secondary memory
View Answer

Answer: a
Explanation: None.

2. Which data type can be stored in register?
a) int
b) long
c) float
d) all of the mentioned
View Answer

Answer: d
Explanation: None.
advertisement
advertisement

3. Which of the following operation is not possible in a register variable?
a) Reading the value into a register variable
b) Copy the value from a memory variable
c) Global declaration of register variable
d) All of the mentioned
View Answer

Answer: d
Explanation: None.

4. Which among the following is the correct syntax to declare a static variable register?
a) static register a;
b) register static a;
c) Both static register a; and register static a;
d) We cannot use static and register together
View Answer

Answer: d
Explanation: None.
advertisement

5. Register variables reside in ________
a) stack
b) registers
c) heap
d) main memory
View Answer

Answer: b
Explanation: None.

6. What will be the output of the following C code?

advertisement
  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         register int x = 0;
  5.         if (x < 2)
  6.         {
  7.             x++;
  8.             main();
  9.         }
  10.     }

a) Segmentation fault
b) main is called twice
c) main is called once
d) main is called thrice
View Answer

Answer: a
Explanation: None.
advertisement

7. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         register int x;
  5.         printf("%d", x);
  6.     }

a) 0
b) Junk value
c) Compile time error
d) Nothing
View Answer

Answer: b
Explanation: None.

8. What will be the output of the following C code?

  1.     #include <stdio.h>
  2.     register int x;
  3.     void main()
  4.     {
  5.         printf("%d", x);
  6.     }

a) Varies
b) 0
c) Junk value
d) Compile time error
View Answer

Answer: d
Explanation: None.

Sanfoundry Global Education & Learning Series – C Programming Language.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

advertisement
advertisement

Leave a Comment

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer & SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage, Advanced C Programming, SAN Storage Technologies, SCSI Internals & Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him @ LinkedIn | Youtube | Instagram | Facebook | Twitter

Check his free tutorial videos on Advanced C Programming. Join his Sanfoundry-Classes telegram channel for all videos and queries on Programming, Data-Structures, Kernel, Personality development and Mentoring.