Font size
Worksheetsunit3 pointers
Total questions: 10
Worksheet time: 5mins
1. Prior to using a pointer variable it should be
Declared
Initialized
Both declared and initialized
None of these
Consider the declaration:
char x[]="WHATIZIT";
char *y="WHATIZIT";
The output of puts(x) an puts(y) will be
Will be the same
Different
Not related
Error
What do the following declaration signify?
char *arr[10];
arr is a array of 10 character pointers.
arr is a array of function pointer.
arr is a array of characters.
arr is a pointer to array of characters.
What is the output of C Program.?
int main()
{
char grade[] = {'A','B','C'};
printf("GRADE=%c, ", *grade);
printf("GRADE=%d", grade);
}
GRADE=some address of array, GRADE=A
GRADE=A, GRADE=some address of array
GRADE=A, GRADE=A
Compiler error
What is the output of C program.?
int main()
{
char grade[] = {'A','B','C'};
printf("GRADE=%d, ", *grade);
printf("GRADE=%d", grade[0]);
}
A A
65 A
65 65
None of the above
What is the output of C program with arrays and pointers.?
int main()
{
int a[3] = {20,30,40};
printf("%d", *(a+1));
}
20
30
40
Compiler error
What is the output of C program with arrays and pointers.?
int main()
{
int size=4;
int a[size];
a[0]=5;
a[1]=6;
a[2]=7;
a[3]=8;
printf("%d %d", *(a+2), a[1]);
}
8 6
7 6
6 6
Compiler error
What is the output of following program?
# include <stdio.h>
void fun(int x)
{
x = 30;
}
int main()
{
int y = 20;
fun(y);
printf("%d", y);
return 0;
}
30
20
Compiler Error
Runtime Error
Output of following program?
# include <stdio.h>
void fun(int *ptr)
{
*ptr = 30;
}
int main()
{
int y = 20;
fun(&y);
printf("%d", y);
return 0;
}
20
30
Compiler Error
Runtime Error
If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?
.
&
*
->
