This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Register Variables – 1”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code?
#include <stdio.h>
int main()
{
register int i = 10;
int *p = &i;
*p = 11;
printf("%d %d\n", i, *p);
}
a) Depends on whether i is actually stored in machine register
b) 10 10
c) 11 11
d) Compile time error
View Answer
Explanation: None.
2. register keyword mandates compiler to place it in machine register.
a) True
b) False
c) Depends on the standard
d) None of the mentioned
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
register static int i = 10;
i = 11;
printf("%d\n", i);
}
a) 10
b) Compile time error
c) Undefined behaviour
d) 11
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
register auto int i = 10;
i = 11;
printf("%d\n", i);
}
a) 10
b) Compile time error
c) Undefined behaviour
d) 11
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
register const int i = 10;
i = 11;
printf("%d\n", i);
}
a) 10
b) Compile time error
c) Undefined behaviour
d) 11
View Answer
Explanation: None.
6. Register storage class can be specified to global variables.
a) True
b) False
c) Depends on the compiler
d) Depends on the standard
View Answer
Explanation: None.
7. Which among the following is wrong for “register int a;”?
a) Compiler generally ignores the request
b) You cannot take the address of this variable
c) Access time to a is critical
d) None of the mentioned
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
void main()
{
register int x = 5;
m();
printf("x is %d", x);
}
void m()
{
x++;
}
a) 6
b) 5
c) Junk value
d) Compile time error
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Get Free Certificate of Merit in C Programming
- Participate in C Programming Certification Contest
- Become a Top Ranker in C Programming
- Take C Programming Tests
- Chapterwise Practice Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Chapterwise Mock Tests: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
- Practice BCA MCQs
- Practice Computer Science MCQs
- Watch Advanced C Programming Videos
- Buy Computer Science Books
- Apply for C Internship