Home > General Studies (Hindi) > Quizzes > C Programming Practice Test: Pointers and Arrays in C
C Programming Practice Test: Pointers and Arrays in C
Fast practice, instant feedback. Timer auto-submits when time’s up.
Avg score: 0% Most missed: “What is the syntax for constant pointer to address (i.e., fixed pointer address)…”
Pointers and Arrays in C quiz on: Pointers and addresses, function arguments, arrays, address arithmetic, character pointers and functions, multidimensional arrays, pointer arrays initialization, command line arguments and complicated declarations. Arrays: Arrays are used to store multiple elements of the same data type in a contiguous block of memory. The index of an array represents the position of an element, starting from 0. Arrays are static, which means that their size is fixed once they are declared. Pointers: Pointers are variables that store the address of another variable or array... Show more
C Programming Practice Test: Pointers and Arrays in C
Time left 00:00
25 Questions

1. 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 %d\n", a, b);
}
2. What substitution should be made to //-Ref such that ptr1 points to variable c in the following C code?
#include
int main()
{
int a = 1, b = 2, c = 3;
int *ptr1 = &a;
int **sptr = &ptr1;
//-Ref
}"
3. Which type of variables can have the same name in a different function?
4. What will be the output of the following C code?
#include
int main()
{
int ary[4] = {1, 2, 3, 4};
int *p = ary + 3;
printf("%d\n", p[-2]);
}
5. How many number of pointer (*) does C have against a pointer variable declaration?
6. What will be the output of the following C code on a 32-bit system?
#include
void main()
{
char *a[10] = {"hi", "hello", "how"};
printf("%d\n", sizeof(a[1]));
}
7. What will be the output of the following C code?
#include
void m(int p)
{
printf("%d\n", p);
}
void main()
{
int a = 6, b = 5;
m(a, b);
printf("%d %d\n", a, b);
}
8. What will be the output of the following C code?
#include
void main()
{
int k = 5;
int *p = &k;
int **m = &p;
printf("%d%d%d\n", k, *p, **p);
}
9. What will be the output of the following C code?
#include
void main()
{
char *s = "hello";
char *n = "cjn";
char *p = s + n;
printf("%c\t%c", *p, s[1]);
}
10. What will be the output of the following C code?
#include
void f(int);
void (*foo)(float) = f;
int main()
{
foo(10);
}
void f(int i)
{
printf("%d\n", i);
}
11. What makes the following declaration denote?
char *str[5];"
12. What will be the output of the following C code?
#include
int main()
{
int i = 0, j = 1;
int *a[] = {&i, &j};
printf("%d", (*a)[0]);
return 0;
}
13. Calling a function f with a an array variable a[3] where a is an array, is equivalent to __________
14. Comment on an array of the void data type.
15. What does argc and argv indicate in command-line arguments?
(Assuming: int main(int argc, char *argv[]) )
16. What will be the output of the following C code?
#include
int add(int a, int b)
{
return a + b;
}
int main()
{
int (*fn_ptr)(int, int);
fn_ptr = add;
printf("The sum of two numbers is: %d", (int)fn_ptr(2, 3));
}
17. What will be the output of the following C code?
#include
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%s", *a + 1);
return 0;
}
18. What will be the output of the following C code?
#include
int main()
{
char *str = "hello world";
char strary[] = "hello world";
printf("%d %d\n", strlen(str), strlen(strary));
return 0;
}
19. What will be the output of the following C code?
#include
void main()
{
struct student
{
int no;
char name[20];
};
struct student s;
no = 8;
printf("%d", no);
}
20. What will be the output of the following C code?
#include
void main()
{
int a[3] = {1, 2, 3};
int *p = a;
int *r = &p;
printf("%d", (**r));
}
21. What are the elements present in the array of the following C code?
int array[5] = {5};"
22. A program that has no command line arguments will have argc _________
23. What type of initialization is needed for the segment “ptr[3] = ‘3’;” to work?
24. What will be the output of the following C code?
#include
int main()
{
int ary[2][3][4], j = 20;
ary[0][0] = &j;
printf("%d\n", *ary[0][0]);
}
25. What will be the output of the following C code?
#include
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}