This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Address Arithmetic – 1”.
Pre-requisite for C Address Arithmetic MCQ set: Video Tutorial on C Pointers.
1. What will be the output of the following C code?
#include <stdio.h>
int main()
{
double *ptr = (double *)100;
ptr = ptr + 2;
printf("%u", ptr);
}
a) 102
b) 104
c) 108
d) 116
View Answer
Explanation:None
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int *p = (int *)2;
int *q = (int *)3;
printf("%d", p + q);
}
a) 2
b) 3
c) 5
d) Compile time error
View Answer
Explanation: None.
3. Which of the following arithmetic operation can be applied to pointers a and b?
(Assuming initialization as int *a = (int *)2; int *b = (int *)3;)
a) a + b
b) a – b
c) a * b
d) a / b
View Answer
Explanation: None.
4. What is the size of *ptr in a 32-bit machine (Assuming initialization as int *ptr = 10;)?
a) 1
b) 2
c) 4
d) 8
View Answer
Explanation: None.
5. Which of following logical operation can be applied to pointers?
(Assuming initialization int *a = 2; int *b = 3;)
a) a | b
b) a ^ b
c) a & b
d) None of the mentioned
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *s = "hello";
char *p = s;
printf("%c\t%c", *(p + 1), s[1]);
}
a) h e
b) e l
c) h h
d) e e
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *s = "hello";
char *p = s;
printf("%c\t%c", *p, s[1]);
}
a) e h
b) Compile time error
c) h h
d) h e
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *s = "hello";
char *n = "cjn";
char *p = s + n;
printf("%c\t%c", *p, s[1]);
}
a) h e
b) Compile time error
c) c o
d) h n
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
- Buy Computer Science Books
- Buy C Books
- Practice BCA MCQs
- Watch Advanced C Programming Videos
- Apply for C Internship