| | |
2d Array
Please support our C advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Sep 2004
Posts: 2
Reputation:
Solved Threads: 0
hi can someone help how to make a program or exampel of program using two dimensional array. Or can someone help me to make program by this problem >Write a program using two dimensional array that searches a number and display the of times it occurs on the list of twelve input value.
I'm asking for help coz my Prof. didn't explain it very well
I'm asking for help coz my Prof. didn't explain it very well
Greetings,
Using a 2-Dimensional array isn't very difficult at all. In fact for simplicity, lets take a look how a 2-Dimensional array looks in all aspects.
We know this array is going to be a 2x3 rectangle. So lets see how this looks:
Not bad at all. How about if we initialize this array:
There are two blocks, with 3 numbers inside each initializing our 2x3 array completlely:
This should all be making sense. To set your array's data outside of the initilization isn't hard at all:
So think of a 2-Dimensional array as a rectangle. Rows and Columns, right and down. Once you have this down, please feel free to ask more questions.
- Stack Overflow
Using a 2-Dimensional array isn't very difficult at all. In fact for simplicity, lets take a look how a 2-Dimensional array looks in all aspects.
int myValue[2][3];We know this array is going to be a 2x3 rectangle. So lets see how this looks:
C Syntax (Toggle Plain Text)
Rows/Columns Column 0 Column 1 Column 2 Column 3 Row 0 myValue[0][0] myValue[0][1] myValue[0][2] myValue[0][3] Row 1 myValue[1][0] myValue[1][1] myValue[1][2] myValue[1][3]
Not bad at all. How about if we initialize this array:
int myValue[2][3] = { {5, -3, 0}, {10, 17, -25} };There are two blocks, with 3 numbers inside each initializing our 2x3 array completlely:
C Syntax (Toggle Plain Text)
Rows/Columns Column 0 Column 1 Column 2 Row 0 5 -3 0 Row 1 10 17 -25
This should all be making sense. To set your array's data outside of the initilization isn't hard at all:
int main() { int myValue[2][3] myValue[0][0] = 5; myValue[0][1] = -3; myValue[0][2] = 0; myValue[1][0] = 10; myValue[1][1] = 17; myValue[1][2] = -25; return 0; }
So think of a 2-Dimensional array as a rectangle. Rows and Columns, right and down. Once you have this down, please feel free to ask more questions.
- Stack Overflow
Following the rules will ensure you get a prompt answer to your question. If posting code, please include BB [code][/code] tags. Your question may have been asked before, try the search facility.
IRC
Channel: irc.daniweb.com
Room: #c, #shell
IRC
Channel: irc.daniweb.com
Room: #c, #shell
![]() |
Similar Threads
- Can I ghost a RAID array??? (Windows NT / 2000 / XP)
- Creating dynamic array structures (C++)
- Array limit (C)
- struct dynamic 2d array alloc (C)
- string to integer array transformation (C)
- Array (Visual Basic 4 / 5 / 6)
Other Threads in the C Forum
- Previous Thread: How to round down (remainders?) in C
- Next Thread: c does not compile-o identifier error
Views: 76343 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C
adobe ansi api array arrays asterisks binarysearch calculate centimeter char command convert copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile csyntax directory dynamic executable fflush file fork forloop frequency getlasterror givemetehcodez graphics gtkgcurlcompiling hacking hardware highest homework i/o inches incrementoperators infiniteloop kernel km lazy linked linkedlist linux linuxsegmentationfault list lists locate logical_drives match matrix microsoft motherboard multi mysql number open opendocumentformat opensource owf pattern pdf performance pointer pointers posix problem probleminc program programming radix recursion recv repetition research scanf scheduling scripting segmentationfault send sequential shape socketprograming spoonfeeding stack standard string strings structures student systemcall testautomation turboc unix user variable voidmain() wab win32 windows.h





