Pointer - Study Mode
[#66] What is the correct way to declare and assign a function pointer? (Assuming the function to be assigned is "int multi(int, int)
")
Correct Answer
(A) int (*fn_ptr)(int, int) = multi
[#67] What will be the output of the following C code? #include <stdio.h>
struct student
{
int no = 5
char name[20]
}
void main()
{
struct student s
s.no = 8
printf("hello")
}
Correct Answer
(B) Compile time error
[#68] What will be the output of the following C code? #include <stdio.h>
void f(int (*x)(int))
int myfoo(int i)
int (*foo)(int) = myfoo
int main()
{
f(foo(10))
}
void f(int (*i)(int))
{
i(11)
}
int myfoo(int i)
{
printf("%d
", i)
return i
}
Correct Answer
(D) 10 Segmentation fault
[#69] What will be the output of the following C code? #include <stdio.h>
void fun(char *k)
{
printf("%s", k)
}
void main()
{
char s[] = "hello"
fun(s)
}
Correct Answer
(A) hello
[#70] What will be the output of the following C code? #include <stdio.h>
int main()
{
int i = 0, j = 1
int *a[] = {&i, &j}
printf("%d", *a[0])
return 0
}
Correct Answer
(C) 0