Exercise: Pointers
Questions for: Pointers
Which statement will you add to the following program to ensure that the program outputs "ExamAdept" on execution?
#include<stdio.h>
int main()
{
char s[] = "ExamAdept";
char t[25];
char *ps, *pt;
ps = s;
pt = t;
while(*ps)
*pt++ = *ps++;
/* Add a statement here */
printf("%s\n", t);
return 0;
}
A:
*pt='';
B:
pt='\0';
C:
pt='\n';
D:
*pt='\0';
Answer: D
No answer description is available. Let's discuss.
Which of the statements is correct about the program?
#include<stdio.h>
int main()
{
int arr[3][3] = {1, 2, 3, 4};
printf("%d\n", *(*(*(arr))));
return 0;
}
A:
Output: Garbage value
B:
Output: 1
C:
Output: 3
D:
Error: Invalid indirection
Answer: D
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the following statements correct about k used in the below statement?
char ****k;
char ****k;
A:
k is a pointer to a pointer to a pointer to a char
B:
k is a pointer to a pointer to a pointer to a pointer to a char
C:
k is a pointer to a char pointer
D:
k is a pointer to a pointer to a char
Answer: B
No answer description is available. Let's discuss.
Discuss About this Question.
In the following program add a statement in the function fun() such that address of a gets stored in j?
#include<stdio.h>
int main()
{
int *j;
void fun(int**);
fun(&j);
return 0;
}
void fun(int **k)
{
int a=10;
/* Add a statement here */
}
A:
**k=a;
B:
k=&a;
C:
*k=&a
D:
&k=*a
Answer: C
No answer description is available. Let's discuss.
Discuss About this Question.
Which of the statements is correct about the program?
#include<stdio.h>
int main()
{
float a=3.14;
char *j;
j = (char*)&a;
printf("%d\n", *j);
return 0;
}
A:
It prints ASCII value of the binary number present in the first byte of a float variable a.
B:
It prints character equivalent of the binary number present in the first byte of a float variable a.
C:
It will print 3
D:
It will print a garbage value
Answer: A
No answer description is available. Let's discuss.
Discuss About this Question.
Ad Slot (Above Pagination)
Discuss About this Question.