21. One of the uses for function pointers in C is . . . . . . . .
22. Comment on the following pointer declaration.
int *ptr, p;
int *ptr, p;
23. What will be the output of the following C code?
#include <stdio.h>
void f(int);
void (*foo)() = f;
int main(int argc, char *argv[])
{
foo(10);
return 0;
}
void f(int i)
{
printf("%d\n", i);
}
#include <stdio.h>
void f(int);
void (*foo)() = f;
int main(int argc, char *argv[])
{
foo(10);
return 0;
}
void f(int i)
{
printf("%d\n", i);
}
24. 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);
}
#include <stdio.h>
void foo(int*);
int main()
{
int i = 10, *p = &i;
foo(p++);
}
void foo(int *p)
{
printf("%d\n", *p);
}
25. What will be the output of the following C code?
#include <stdio.h>
void (*(f)())(int, float);
typedef void (*(*x)())(int, float);
void foo(int i, float f);
int main()
{
x p = f;
p();
}
void (*(f)())(int, float)
{
return foo;
}
void foo(int i, float f)
{
printf("%d %f\n", i, f);
}
#include <stdio.h>
void (*(f)())(int, float);
typedef void (*(*x)())(int, float);
void foo(int i, float f);
int main()
{
x p = f;
p();
}
void (*(f)())(int, float)
{
return foo;
}
void foo(int i, float f)
{
printf("%d %f\n", i, f);
}
26. What will be the output of the following C code?
#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
#include <stdio.h>
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
s.no = 8;
printf("%d", s.no);
}
27. What are the elements present in the array of the following C code?
int array[5] = {5};
int array[5] = {5};
28. What will be the output of the following C code?
#include <stdio.h>
struct student
{
int no;
char name[20];
};
void main()
{
student s;
s.no = 8;
printf("hello");
}
#include <stdio.h>
struct student
{
int no;
char name[20];
};
void main()
{
student s;
s.no = 8;
printf("hello");
}
29. 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);
}
#include <stdio.h>
void foo(float *);
int main()
{
int i = 10, *p = &i;
foo(&i);
}
void foo(float *p)
{
printf("%f\n", *p);
}
30. What will be the output of the following C code?
#include <stdio.h>
void main()
{
char *a[10] = {"hi", "hello", "how"};
int i = 0, j = 0;
a[0] = "hey";
for (i = 0;i < 10; i++)
printf("%s\n", a[i]);
}
#include <stdio.h>
void main()
{
char *a[10] = {"hi", "hello", "how"};
int i = 0, j = 0;
a[0] = "hey";
for (i = 0;i < 10; i++)
printf("%s\n", a[i]);
}
Read More Section(Pointer)
Each Section contains maximum 100 MCQs question on Pointer. To get more questions visit other sections.