This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Pointers and Function Arguments – 1”.
Pre-requisite for C Pointers and Function Arguments MCQ set: Video Tutorial on C Pointers.
1. What will be the output of the following C code?
#include <stdio.h>
void foo(int*);
int main()
{
int i = 10;
foo((&i)++);
}
void foo(int *p)
{
printf("%d\n", *p);
}
a) 10
b) Some garbage value
c) Compile time error
d) Segmentation fault/code crash
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
void foo(int*);
int main()
{
int i = 10, *p = &i;
foo(p++);
}
void foo(int *p)
{
printf("%d\n", *p);
}
a) 10
b) Some garbage value
c) Compile time error
d) Segmentation fault
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
void foo(float *);
int main()
{
int i = 10, *p = &i;
foo(&i);
}
void foo(float *p)
{
printf("%f\n", *p);
}
a) 10.000000
b) 0.000000
c) Compile time error
d) Undefined behaviour
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 97, *p = &i;
foo(&i);
printf("%d ", *p);
}
void foo(int *p)
{
int j = 2;
p = &j;
printf("%d ", *p);
}
a) 2 97
b) 2 2
c) Compile time error
d) Segmentation fault/code crash
View Answer
Explanation: None.
5. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 97, *p = &i;
foo(&p);
printf("%d ", *p);
return 0;
}
void foo(int **p)
{
int j = 2;
*p = &j;
printf("%d ", **p);
}
a) 2 2
b) 2 97
c) Undefined behaviour
d) Segmentation fault/code crash
View Answer
Explanation: None.
6. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 11;
int *p = &i;
foo(&p);
printf("%d ", *p);
}
void foo(int *const *p)
{
int j = 10;
*p = &j;
printf("%d ", **p);
}
a) Compile time error
b) 10 10
c) Undefined behaviour
d) 10 11
View Answer
Explanation: None.
7. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 10;
int *p = &i;
foo(&p);
printf("%d ", *p);
printf("%d ", *p);
}
void foo(int **const p)
{
int j = 11;
*p = &j;
printf("%d ", **p);
}
a) 11 11 11
b) 11 11 Undefined-value
c) Compile time error
d) Segmentation fault/code-crash
View Answer
Explanation: None.
8. What will be the output of the following C code?
#include <stdio.h>
int main()
{
int i = 10;
int *const p = &i;
foo(&p);
printf("%d\n", *p);
}
void foo(int **p)
{
int j = 11;
*p = &j;
printf("%d\n", **p);
}
a) 11 11
b) Undefined behaviour
c) Compile time error
d) Segmentation fault/code-crash
View Answer
Explanation: None.
9. Which of the following is the correct syntax to send an array as a parameter to function?
a) func(&array);
b) func(#array);
c) func(*array);
d) func(array[size]);
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
- Apply for C Internship
- Buy C Books
- Watch Advanced C Programming Videos
- Apply for Computer Science Internship
- Buy Computer Science Books