Current location: Hot Scripts Forums » Programming Languages » C/C++ » Two dimensional array


Two dimensional array

Reply
  #1 (permalink)  
Old 08-19-07, 11:07 PM
Volkun Volkun is offline
New Member
 
Join Date: Aug 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Question Two dimensional array

I have a test question that I need help in understanding.

Given the following two-dimensional arrary declaration and initialization:

int a[ ][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}};

what is the value of the expression *(a[1]+[2])?

choices for answers are:

a. 3
b. 6
c. 7
d. The subscript exceeds array bounds.

My book (C in Dissection) is of no help.

Thank you.

Vulkun
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 08-20-07, 04:20 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,074
Thanks: 11
Thanked 88 Times in 83 Posts
Topic moved to C.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 08-29-07, 07:35 AM
King Coder King Coder is offline
Community VIP
 
Join Date: Jan 2006
Posts: 703
Thanks: 0
Thanked 0 Times in 0 Posts
The expression *(a[1]+[2]) looks a little messed up (unless C allows the syntax). What are you wanting with the [2]? I think it should be *(a[1]+2). In this case the answer is 7.
__________________
my site
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Make A New Array From An Old Array (Excluding 1 Array Element) w2n PHP 14 08-17-07 04:24 PM
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' Dr. Forensics PHP 3 07-15-06 04:54 PM
Sorting a massive multidimensional array dave111 PHP 1 12-12-05 05:09 PM
Serializing a set of arrays dannyallen PHP 2 10-11-04 04:04 AM
linking to iframe not working :( j0d JavaScript 5 01-19-04 09:14 PM


All times are GMT -5. The time now is 10:13 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.