943,614 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 677
  • C++ RSS
Nov 20th, 2007
0

C Arrays

Expand Post »
hello guys:
i awais ahmad has a simple problem with the two dimensional array.
that is how to get two values in one column of the array
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Awais Ahmad is offline Offline
5 posts
since Nov 2007
Nov 20th, 2007
0

Re: C Arrays

Sometimes when English isn't your native language it is even more difficult to explain what you want to do than it is for us native English speakers. To use multidiminsional arrays you can do something like this:

int array[2][2];

which declares a variable on the stack with enough memory for 4 ints. Now to get the information into that array you can do several things. Here's one way:
C++ Syntax (Toggle Plain Text)
  1. for(int i = 0; i < 2; ++i)
  2. {
  3. for(int j = 0; j < 2; ++i)
  4. {
  5. cout <<"enter a value" << endl;
  6. cin >> array[i][j];
  7. }
  8. }
  9.  
  10. and to dispay the values you use another nested loop except the body would be something like:
  11.  
  12. //pseudocode to display array as a table
  13. for()
  14. for()
  15. cout << array[i][j] << ' ';
  16. cout << endl;
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Help with atoi
Next Thread in C++ Forum Timeline: Visual Studio Problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC