×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
To Your Posts
• Keyword Search
• One-Click Access To Your
Favorite Forums
• Automated Signatures
On Your Posts
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

2d arrays

 Forum Search FAQs Links MVPs

2d arrays

(OP)
can you store info from a user in a 2d array and then add two numbers together.

RE: 2d arrays

Could you please elabourate? I read your question and it almost sounds like you mean a 2 element 1 dimensional array...

and that would be...

dim nums(1 to 2)

for a = 1 to 2 ' this is unnessesary
input nums(a)
next a
result = 0
for a = 1 to 2 ' this is really unnessesary. It's embarassing.
result = result + nums(a)
next a

print "the result is ";result

...but...

RE: 2d arrays

a 2d array would be like DIM array(5,5) - do you mean adding two of those together like matrix addition?

[4,4] + [1,0] = [4,4]
[5,3]    [0,1]     [5,3]

if a line is unnessasary then why write it, you FOR-NEXT loop is actually more code and slower than just doing
result = result + nums(a)
result = result + nums(b)

RE: 2d arrays

(OP)
qbasicking is right. but i need to no how to add a 2d array like this

dim n(3,3)

x = n(3+3)
' i no this is wrong but its the only to describe it

and id also like to no how to display just one of the two
arrays like:

dim n(4,2)

print n(3, ) ' just show the first one

RE: 2d arrays

Is this what you mean?

CODE

DIM Test(1, 2)
CLS

Test(1, 1) = 5
Test(1, 2) = 15
Test(1, 0) = Test(1, 2) + Test(1, 1)
FOR Cycle = 2 TO 0 STEP -1
PRINT "Test (1," + STR$(Cycle) + ") = ", PRINT Test(1, Cycle) NEXT Cycle print "----------------" : Print sleep 4 Test(0, 1) = 3 Test(0, 2) = 4 FOR Cycle = 1 TO 2 PRINT "Test (0," + STR$(Cycle) + ") = ",
PRINT Test(0, Cycle)
NEXT Cycle
Test(0, 0) = Test(0, 2) + Test(0, 1)
PRINT Test(0, 0)
print "----------------" : Print
sleep 4

print "combined total of Temp(0,0) + Temp(1,0);"
print
print Test(0,0) + Test(1,0)
END

Is this what you are talking about?
--MiggyD

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!

Already a member? Close this window and log in.