Geeks Talk

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.

convert one dimansional array to two dimansional array

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 ...

Go Back   Geeks Talk > Software Development > C and C++
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 04-06-2007
Expert Member
 
Join Date: Feb 2007
Posts: 1,279
Thanks: 0
Thanked 192 Times in 154 Posts
Geek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura aboutGeek_Guest has a spectacular aura about
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.
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-24-2007
Contributing Member
 
Join Date: Jul 2007
Location: India
Posts: 31
Thanks: 6
Thanked 4 Times in 4 Posts
kamanianil is on a distinguished road
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?
Reply With Quote
  #3 (permalink)  
Old 08-06-2007
Junior Member
 
Join Date: Jul 2007
Location: coimbatore
Posts: 26
Thanks: 4
Thanked 6 Times in 3 Posts
govindaraj123 is on a distinguished road
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 .
Reply With Quote
  #4 (permalink)  
Old 12-20-2007
Contributing Member
 
Join Date: Nov 2007
Location: bangalore
Posts: 54
Thanks: 6
Thanked 6 Times in 4 Posts
rahulvegi is on a distinguished road
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.
Reply With Quote
  #5 (permalink)  
Old 12-20-2007
Contributing Member
 
Join Date: Jul 2007
Location: India
Posts: 31
Thanks: 6
Thanked 4 Times in 4 Posts
kamanianil is on a distinguished road
Smile Re: convert one dimansional array to two dimansional array

Quote:
Originally Posted by rahulvegi View Post
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.
thnks...
Reply With Quote
  #6 (permalink)  
Old 12-22-2007
Contributing Member
 
Join Date: Dec 2007
Posts: 48
Thanks: 1
Thanked 8 Times in 7 Posts
sk_seeker is on a distinguished road
Re: convert one dimansional array to two dimansional array

Quote:
Originally Posted by Geek_Guest View Post
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.
Supriya,

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??
Reply With Quote
  #7 (permalink)  
Old 12-22-2007
Junior Member
 
Join Date: Dec 2007
Location: india
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
srinivasneeluri is on a distinguished road
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
Reply With Quote
Reply

  Geeks Talk > Software Development > C and C++

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


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


All times are GMT -4. The time now is 10:42 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved