GeekInterview.com
Series: Subject:
Question: 168 of 270

Are the expressions arr and &arr same for an array of integers?

Asked by: Interview Candidate | Asked on: Jun 24th, 2005
Showing Answers 1 - 6 of 6 Answers
Purvi mehta

Answered On : Nov 8th, 2006

Ans:- No,&arr will store the address of array.

  
Login to rate this answer.
yuvraj

Answered On : Mar 13th, 2007

The answer is YES bcoz both arr and &arr gives the base address of an array.
You can try it by a simple example
void main()
{
 int arr[10];
 printf("%dn",arr);
 printf("%d",&arr);
}

  
Login to rate this answer.
Jyotiranjan Moahnty

Answered On : Oct 8th, 2007

#include<stdio.h>
int main()
{
 int arr[2];
 printf("%dn",arr);
 printf("%dn",(arr+1));
 printf("%dn",&arr);
 printf("%dn",(&arr+1));
}
 

Try it, I think it is the better example for you to understand that, arr and &arr is not same. Their starting address is same, but the value in that memory is not same.

I think you are a student. I appreciate, your involvement with this  kind of things.

  
Login to rate this answer.
indirakannan26

Answered On : Aug 12th, 2008

View all answers by indirakannan26

Sorry, it is not same because arr stores the value where as &arr is the address of that value.

  
Login to rate this answer.
KishoreKNP

Answered On : Dec 4th, 2009

View all answers by KishoreKNP

Arr and &Arr both are same, which will return the address of first element of the array. For example

void main()
{
   char arr[10] = "Kishore";
   printf("n%u : %u", a, &a);
}
Output:
~~~~~

65516 : 65516

  
Login to rate this answer.
Mohamed

Answered On : May 8th, 2013

Actually arr and &arr are different. arr holds the base address of the array arr[], but &arr holds the address of the entire array. but both expressions points to the same base address.

Code
  1.   #include<stdio.h>
  2. int main()
  3. {
  4.  int arr[2]={5,6};
  5.  printf("%u
  6. ",arr);
  7.  printf("%u
  8. ",(arr+1));
  9.  printf("%u
  10. ",&arr);
  11.  printf("%u
  12. ",(&arr+1));
  13. return 0;
  14. }
  15.  

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Ads

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.