C Programming - Arrays - Discussion
Discussion Forum : Arrays - Find Output of Program (Q.No. 9)
9.
What will be the output of the program if the array begins at address 65486?
#include<stdio.h>
int main()
{
int arr[] = {12, 14, 15, 23, 45};
printf("%u, %u\n", arr, &arr);
return 0;
}
Answer: Option
Explanation:
Step 1: int arr[] = {12, 14, 15, 23, 45}; The variable arr is declared as an integer array and initialized.
Step 2: printf("%u, %u\n", arr, &arr); Here,
The base address of the array is 65486.
=> arr, &arr is pointing to the base address of the array arr.
Hence the output of the program is 65486, 65486
Discussion:
17 comments Page 2 of 2.
Krutika said:
9 years ago
In simpler terms, the starting address of an array is equal to the starting address of the first element in an array.
Kajal said:
5 years ago
%u range is 0 to 65535 where int is 2B so how it can handle 65486?
Please explain.
Please explain.
Anu said:
9 years ago
I can't understand arr+1,&arr+1. Please explain in detail.
Ramya said:
8 years ago
@Puneet.
Why your multiplying size of (int) with 5?
Why your multiplying size of (int) with 5?
Puneet said:
10 years ago
&arr+1 = Base address+5*size of (int).
Karthik said:
1 decade ago
Can anyone explain it briefly?
Balaji said:
8 years ago
How to find base address?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers