In this FREE six-day email course, you'll learn from Janis Griffin, Database Performance Evangelist. She'll teach 12 steps that you can use to optimize your queries as much as possible and see measurable results in your work. Get started today!

Hello,

I was wondering If you would care to help me on this! I have a program that has array[], like x[k], and this gives different values of x but i want to compare the xs how can I do that !

exple :

for (k=0;k<10;k++){

x[k]= function(a[k], b[k]);

printf("x=%f\n", x[k]);

}

and I want to compare all xs and get the bigger value ! How can I do that ! pleasssse

I was wondering If you would care to help me on this! I have a program that has array[], like x[k], and this gives different values of x but i want to compare the xs how can I do that !

exple :

for (k=0;k<10;k++){

x[k]= function(a[k], b[k]);

printf("x=%f\n", x[k]);

}

and I want to compare all xs and get the bigger value ! How can I do that ! pleasssse

Hi Besbous,

If you're just looking for the largest value, loop through the entire array and "save" the biggest one.

int Largest;

int Array[SomeSize];

int index;

Largest = Array[0];

for (index = 1; index < SomeSize; index++)

if (Array[index] > Largest)

Largest = Array[index];

That's all that there is to it!

Good Luck,

Kent

hi Kdo,

in my program I wanna get the the bigget value of all r1[k], of all g1[k] and of all b1[k], coz each r1[k].. is related to g_y[k] and g_x[k],

so if i can get the largest of all r1[k] is it possible to get the g_x[k] and g_y[k] associeted to ?

for(k=0;k<10;k++){

r1[k]=rgb(img_src,g_y[k],g

g1[k]=rgb(img_src,g_y[k],g

b1[k]=rgb(img_src,g_y[k],g

printf("R=%d, G=%d, B=%d\n", r1[k], g1[k], b1[k]);

How can you detect a question and post a reply all in two minutes!!!

Akshay,

this is not homework and if it is, it a small part of a big project

Besbous,

>so if i can get the largest of all r1[k] is it possible to get the g_x[k] and g_y[k] associeted to ?

If there is some correspondence between the values, then the index i at which you found biggest r1[], the same index will have biggest values in g_x[] and g_y[]

otherwise, you can run the same loop as r1[] for g_x[] and g_y[] to get the largest value ... all you need to do is replace r1[] by g_x[] or g_y[] as required

actually I don t need the biggest values in g_x[k] and g_y[k], I need the g_x[k] and g_y[k] related to the biggest r1[k]! but actually I tried but couldn t get the biggest value of r1[k]! so im kinda confused ! :(!

This is just as easy. When you find an r1[] that is larger than the previous, save it and the g_x[] and g[] values.

if (r1[k] > LargestR1)

{

LargestR1 = r1[k];

LargestGX = g_x[k];

LargestGY = g_y[k];

}

Still waiting for an answer to my previous question,

Kent

anyway probably I shouldn t have asked that !

thx for your help guys !

Don't be bashful about asking questions! That's what the board is for and there are quite a few of us willing to help. The three people that have responded here are three of the most prolific responders in the C thread. (Actually, Sunny's in his own league as far as number of answers is concerned -- the rest of kind of pick up the scraps.)

And as you've probably gathered, we're a bit paranoid about providing answers to homework. This link will help you to understand why:

http://www.experts-exchange.com/Programming/Programming_Languages/C/Q_20690354.html

Anyway, glad that we could help

Kent

Yeah I totally understand ! and of course you re right ! and you guys are really great with ur answers ! just sometimes after 9 hours of sitting facing the computer and trying to make a Robot distinguish colors... is tiring, so it doesnt help to see some simple stuff! Oh well!! :)

You guys are great ! Thx a lot ! Hope I can help too some other time !

for Besbous... if u were satisfied with the solution, wouldnt it have been nicer to award with A grade...

akshay

LOL Kent, how did you imagine that ... you are more than 3000 points ahead of me for the month of december<gasp>... you have got a weird imagination or are you being too humble ? ;o)

and I admire your memory ... where did you dig out that question from ?

Hi Sunny,

December is a bit of an anomaly. Since most schools in the western hemisphere give their students quite a bit of time off (1 to 3 weeks) there are a lot fewer questions from students. I don't know what schedule students keep in your time zone, but there seems to be a lot fewer questions posted during your "prime time". I'm sure that things will normalize the first week of January.

That thread has bothered me ever since I got involved in it. Then to have the snivelling wimp develop a "I did it and you can't do anything about it" attitude really torched me. I'd had an offline discussion with one of the mods about it and offerred to use my university contacts to contact the poster's administration, but (much to the mod's credit) the request was declined since it went againt EE's rules. OTOH, by now the poster is reaping his own rewards and trying to figure out how and engineering degree barely qualifies him to ask, "eat in or take out"?

Well I m not quite familiar with the grade thing ! i don t know how u grade! but anyway that s what i would have given my self ! coz asking the question made me see some things which helped me to the problem ! well sorry if by mistake I sounded stingy!

I felt that too... however, I am not too sure of this....

>I'm sure that things will normalize the first week of January.

;o)

Boy, you did go to extremes to "teach" her a lesson

>by now the poster is reaping his own rewards and trying to figure out how and engineering degree barely qualifies him to

>ask, "eat in or take out"?

that was her pet peeve, call her a him ... he he

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

I read it as homework too, and thought about how to best answer it. Based on not knowing of any C course where a complete programming assignment is anything this trivial, I offered up the solution. Looking back, I went too far and should have just left instructions. I apologize to you and the rest of the membership.

We now have a follow-up to the original question and it appears that this may not be homework, but I still went too far.

Hi Besbous,

Getting the largest value from a list is trivial, as I've shown you. Before I offer any more solutions I'd like an assurance that this is not homework. The rules of the board expressly forbid the experts from doing other people's homework.

How is it that you're deep enough into programming to be evaluating pixel values, but can't write a simple maximum() function?

Kent