Pointer - Study Mode
[#86] What will be the output of the following C code? #include <stdio.h>
int main()
{
const int ary[4] = {1, 2, 3, 4}
int *p
p = ary + 3
*p = 5
printf("%d
", ary[3])
}
Correct Answer
(B) 5
[#87] What will be the output of the following C code? #include <stdio.h>
void foo( int[] )
int main()
{
int ary[4] = {1, 2, 3, 4}
foo(ary)
printf("%d ", ary[0])
}
void foo(int p[4])
{
int i = 10
p = &i
printf("%d ", p[0])
}
Correct Answer
(C) 10 1
[#88] What will be the output of the following C code? #include <stdio.h>
void main()
{
int a[3] = {1, 2, 3}
int *p = a
printf("%p %p", p, a)
}
Correct Answer
(A) Same address is printed
[#89] What will be the output of the following C code (run without any command line arguments)? #include <stdio.h>
int main(int argc, char *argv[])
{
while (*argv != NULL)
printf("%s
", *(argv++))
return 0
}
Correct Answer
(B) Executable file name
[#90] What will be the output of the following C code? #include <stdio.h>
void m(int *p)
{
int i = 0
for(i = 0
i < 5
i++)
printf("%d ", p[i])
}
void main()
{
int a[5] = {6, 5, 3}
m(&a)
}
Correct Answer
(B) 6 5 3 0 0