GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Placement Papers  >  Wipro  >  Technical
Go To First  |  Previous Question  |  Next Question 
 Technical  |  Question 56 of 157    Print  
main()
{
int a[]={0 1 2 3};
int *b;
b=&a[2];
printf("%d",b[-1]);
}

TECHNICAL INTERVIEW


  
Total Answers and Comments: 10 Last Update: December 14, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
November 18, 2005 03:56:19   #1  
Suhas Member Since: November 2005   Contribution: 24    

RE: main(){int a[]={0 1 2 3};int *b...

3


 
Is this answer useful? Yes | No
February 19, 2006 12:12:36   #2  
swaant        

RE: main(){int a[]={0 1 2 3};int *b...
the ans
 
Is this answer useful? Yes | No
February 19, 2006 12:12:37   #3  
swaant        

RE: main(){int a[]={0 1 2 3};int *b...
the ans is
 
Is this answer useful? Yes | No
February 19, 2006 12:13:35   #4  
swaant        

RE: main(){int a[]={0 1 2 3};int *b...

ans is 1


 
Is this answer useful? Yes | No
June 18, 2006 13:34:54   #5  
purani86 Member Since: June 2006   Contribution: 10    

RE: main(){int a[]={0 1 2 3};int *b...
error.since array index cannot be negative
 
Is this answer useful? Yes | No
September 01, 2006 11:05:09   #6  
Prabhu.T.S        

RE: main(){int a[]={0 1 2 3};int *b...

Declaration syntax error in fn. main()

Elements in the array should be seperated by comma while declaration.


 
Is this answer useful? Yes | No
October 05, 2007 15:59:39   #7  
bhoji_005        

RE: main(){int a[]={0 1 2 3};int *b...
main()
{
int a[] {0 1 2 3};
int *b;
b &a[2];
printf(" d" b[-1]);
}
the ans is :error
why because of b[-1] indicates subscript of -1.....
there is no negetive subscrpts.......

 
Is this answer useful? Yes | No
March 21, 2008 21:29:22   #8  
araghav_23 Member Since: March 2008   Contribution: 2    

RE: main()n{nint a[]={0 1 2 3};nint *b;nb=&a[2];nprintf("%d",b[-1]);n}nTECHNICAL INTERVIEW
its a fact that the array index cannot be negative but i ran the program on both linux compiler and turboc for both of which i got '1' as the output

can anyone interpret this and explain me the concept plzzzzzzzzz

 
Is this answer useful? Yes | No
March 30, 2008 12:09:37   #9  
divinegeek Member Since: March 2008   Contribution: 1    

RE: main()n{nint a[]={0 1 2 3};nint *b;nb=&a[2];nprintf("%d",b[-1]);n}nTECHNICAL INTERVIEW
answer will be 1.........
because a[2] 2
and when it will calculate b[-1] answer is 1............

 
Is this answer useful? Yes | No
December 13, 2008 14:40:00   #10  
Bhoomika sharma Member Since: December 2008   Contribution: 40    

RE: main()n{nint a[]={0 1 2 3};nint *b;nb=&a[2];nprintf("%d",b[-1]);n}nTECHNICAL INTERVIEW
It's logical and easy. See we have a[] i.e. assigned with a set of values. Now a pointer b is been referred to the base address of 2nd position of the array's location i.e. the pointer b is a pointer of arrays which store the second location of array as its first location in the pointer's base address i.e. b[0] contains a[2] value as its value thus the previous value is been stored as its b[-1] value.

So frnd ans is thus : 1

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape