C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 11)
11.
What will be the output of the program?
#include<stdio.h>

int main()
{
    int arr[2][2][2] = {10, 2, 3, 4, 5, 6, 7, 8};
    int *p, *q;
    p = &arr[1][1][1];
    q = (int*) arr;
    printf("%d, %d\n", *p, *q);
    return 0;
}
8, 10
10, 2
8, 1
Garbage values
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
58 comments Page 3 of 6.

Kshirod said:   7 years ago
Good explanation, Thanks @Rahul.

Amaan said:   7 years ago
@Rahul.

You explained it very well, Thanks.

Shalini said:   7 years ago
Good explanation. Thanks All.

Vaishu said:   7 years ago
Is *q always take the first element of an array?

Swetha K M said:   7 years ago
Nice explanations. Thank you all.

Rashmu Jho said:   9 years ago
Nice explanation @Rahul.

Sairam said:   7 years ago
Thank you @Rahul.

Sanjay said:   1 decade ago
Thank you sagar.

Sakshi munya said:   6 years ago
Thank you @Rahul Sharma.

Ritu said:   6 years ago
@Rahul Sharma.

Thank you, you have explained it very well.


Post your comments here:

Your comments will be displayed after verification.