Prepare for your Next Interview
|
Welcome to the Geeks Talk forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
This is a discussion on convert one dimansional array to two dimansional array within the C and C++ forums, part of the Software Development category; Question asked by visitor Ms.Supriya Ahire. Hello All, Plz send me solution for following question... program to convert one dimansional array to two dimansional array . Thanks & Regards, Ms.Supriya ...
|
|||||||
|
|||
|
convert one dimansional array to two dimansional array
Question asked by visitor Ms.Supriya Ahire.
Hello All, Plz send me solution for following question... program to convert one dimansional array to two dimansional array . Thanks & Regards, Ms.Supriya Ahire. |
| Sponsored Links |
|
|||
|
Re: convert one dimansional array to two dimansional array
two dimenation mean second dimention indicates some field which will vary depends on user ?
do you guess what the user give the size of second dimention? |
|
|||
|
Re: convert one dimansional array to two dimansional array
suppose we do the following c code
int a[5],i; here i declared a is an one dimentional array . After compilation it is not possible to convert into two dimensional . |
|
|||
|
Re: convert one dimansional array to two dimansional array
if the single dimentional array has to 5 elements like
int a[5], which stores elements in single row. but in two dimentional we have row and coloumn. now we change above in to two dimentional int a[5][]; the declaration tells a is a variable of type integer which has 5 rows and 0 coloumns and now write your program in two dimentional. |
|
|||
|
Quote:
|
|
|||
|
Re: convert one dimansional array to two dimansional array
Quote:
You need to clarify this question better. Lets consider an example. 1. int arr_of_colors[3] = {red, orange, black}; This is a One-dimensional array. 2. int favorite_color [person][favorite color]; This is a two dimensional array: one dimension is the person, and second dimension is the favorite color. 3. So, would it make sense to say "convert one dimensional array to a two dimensional array??" It does not to me. So, can you clarify your question?? |
|
|||
|
convert one dimansional array to two dimansional array
Part i: statically allocated two dimensional arrays are defined using a syntax of type arrayname [rows][cols]; they are accessed in the same way as one-dimensional arrays: arrayname[r][c] accesses the value at row r, column c. Write a program that creates a two-dimensional array of integers with 5 rows and 3 columns, initializes each value to 0, and then writes out the array, row by row, one row per line. Passing multidimensional arrays is a little bit harder than passing one-dimensional arrays. Here is a sample header: const int numcolumns=15; // possibly more code here... Void foo(int my2darray[][numcolumns]) // notice we must tell how // many columns in the array // but must not how many rows... { // the code } main() { int myarray[5][numcolumns]; foo(myarray); } modify your previous program to pass its array to an initialize function that initializes the array, and to a print function that outputs the array. Handin problem 1: as with one-dimensional arrays, it is annoying to require different syntax for declaring and passing the arrays. Modify your array.h and array.c solutions (from cs 180) to work for a two-dimensional array (e.g. Create an array2d class). You will need constants for maxrows, maxcolumns, and class variables for numrows, numcoluns (as opposed to just length). Test your program by modifying the previous program to work with your new class. Now u happy . Why u waste time in sending mails , go to google search man .... Bye.. Have a nice day
![]()
|
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| accessing elemnts in a array | bvani | PERL | 7 | 02-06-2009 07:04 AM |
| Help on Dynamic Array | nancyphilips | C and C++ | 8 | 12-25-2007 09:59 AM |
| Getting a list of ipaddress from the array using perl | anushya | Scripting | 1 | 02-10-2007 02:42 AM |
| Convert PowerPoint into video | JobHelper | Geeks Lounge | 0 | 02-09-2007 06:01 PM |
| cursor to array. | Barbie | Oracle | 1 | 02-06-2007 08:57 AM |