Here is a listing of C Objective Questions on “Pointers and Function Arguments”:
1. Which of the following can never be sent by call-by-value?
a) Variable
b) Array
c) Structures
d) Both Array and Structures
Answer: b
Clarification: None.
2. Which type of variables can have the same name in a different function?
a) Global variables
b) Static variables
c) Function arguments
d) Both static variables and Function arguments
Answer: d
Clarification: None.
3. Arguments that take input by user before running a program are called?
a) Main function arguments
b) Main arguments
c) Command-Line arguments
d) Parameterized arguments
Answer: c
Clarification: None.
4. What is the maximum number of arguments that can be passed in a single function?
a) 127
b) 253
c) 361
d) No limits in number of arguments
Answer: b
Clarification: None.
5. What will be the output of the following C code?
-
#include
-
void m(int *p, int *q)
-
{
-
int temp = *p; *p = *q; *q = temp;
-
}
-
void main()
-
{
-
int a = 6, b = 5;
-
m(&a, &b);
-
printf("%d %dn", a, b);
-
}
a) 5 6
b) 6 5
c) 5 5
d) 6 6
Answer: a
Clarification: None.
6. What will be the output of the following C code?
-
#include
-
void m(int *p)
-
{
-
int i = 0;
-
for(i = 0;i < 5; i++)
-
printf("%dt", p[i]);
-
}
-
void main()
-
{
-
int a[5] = {6, 5, 3};
-
m(&a);
-
}
a) 0 0 0 0 0
b) 6 5 3 0 0
c) Run time error
d) 6 5 3 junk junk
Answer: b
Clarification: None.
7. What will be the output of the following C code?
-
#include
-
void m(int p, int q)
-
{
-
int temp = p;
-
p = q;
-
q = temp;
-
}
-
void main()
-
{
-
int a = 6, b = 5;
-
m(a, b);
-
printf("%d %dn", a, b);
-
}
a) 5 6
b) 5 5
c) 6 5
d) 6 6
Answer: c
Clarification: None.
8. What will be the output of the following C code?
-
#include
-
void m(int p, int q)
-
{
-
printf("%d %dn", p, q);
-
}
-
void main()
-
{
-
int a = 6, b = 5;
-
m(a);
-
}
a) 6
b) 6 5
c) 6 junk value
d) Compile time error
Answer: d
Clarification: None.
9. What will be the output of the following C code?
-
#include
-
void m(int p)
-
{
-
printf("%dn", p);
-
}
-
void main()
-
{
-
int a = 6, b = 5;
-
m(a, b);
-
printf("%d %dn", a, b);
-
}
a) 6
b) 6 5
c) 6 junk value
d) Compile time error
Answer: d
Clarification: None.