C Arrays

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Nov 2007
Posts: 3
Reputation: Awais Ahmad is an unknown quantity at this point 
Solved Threads: 0
Awais Ahmad Awais Ahmad is offline Offline
Newbie Poster

C Arrays

 
0
  #1
Nov 20th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,688
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 265
Lerner Lerner is offline Offline
Posting Virtuoso

Re: C Arrays

 
0
  #2
Nov 20th, 2007
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:
  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;
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC