User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 456,495 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,709 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 1386 | Replies: 1
Reply
Join Date: Jul 2004
Posts: 64
Reputation: koh is an unknown quantity at this point 
Rep Power: 5
Solved Threads: 0
koh koh is offline Offline
Junior Poster in Training

Array in talbe (problem)

  #1  
Aug 8th, 2004
here is the question:
Use a two-dimensional array called price to hold the prices for Proton’s car
regarding to the models and CC as listed below.

--------------------------------------------------------------------------
in 2d array..i could get
(for example)
void disp(a[][3]);
int main()
{
num[3][2] = { {1,2},{4,5},{7,8} }
disp(num);
return 0;
}
void disp(a[][3])
{
for (int i=1; i<=3 ; i++)
for (int i=1; i<=2 ; i++)
cout << a[i][j] << endl;
}
--------------------------------------------------------------------------
my question is:
how do i seperate the i and j so i could form like a table..
something like this:
model price
i j
i+1 j+1
i+2 j+2
.....and so on..
instead of
1 2
4 5
7 8
All i want is to spread i and j wide....
p.s Get what i mean??
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jun 2004
Posts: 604
Reputation: freesoft_2000 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 6
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: Array in talbe (problem)

  #2  
Aug 8th, 2004
Hi everyone,

Do not use a nested loop but just use a single input variable with a counter like variable

Try this

int k=0;
for(i = 0;i<3;i++)
{
k = k+1;
j = i;
printf("%d "a[i+k][j+k])
}

I hope you this helps you

Yours sincerely

Richard West
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 3:24 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC