943,837 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 1776
  • C RSS
Aug 8th, 2004
0

Array in talbe (problem)

Expand Post »
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??
Similar Threads
koh
Reputation Points: 11
Solved Threads: 0
Junior Poster in Training
koh is offline Offline
73 posts
since Jul 2004
Aug 8th, 2004
0

Re: Array in talbe (problem)

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
Reputation Points: 25
Solved Threads: 10
Practically a Master Poster
freesoft_2000 is offline Offline
623 posts
since Jun 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Visual Studio 6.0.. Frozen In Time
Next Thread in C Forum Timeline: Decimal Problem In C





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC