Click here to Skip to main content
14,325,446 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have a set of numbers (6,78,64,-1,6,-1), (those are not in array and that values get from a loop reading).From that numbers, I want to a method to find the minimum value [that minimum shouldn't be negative value(-1)].

Like this,
67,8,9,2,34,-1,5 -------; minimum = 2
if all values are (-1) then -1,-1,-1,-1,-1,-1------ ; minimum =-1

please anyone suggest a method? Thanks in advance.!
Updated 21-Nov-15 4:55am
Tomas Takac 21-Nov-15 11:01am
That's a nice homework. What have you tried? Where are you stuck?
BillWoodruff 21-Nov-15 22:24pm
Show us your code.
Rate this:
Please Sign up or sign in to vote.

Solution 1

No, a big NO. No one's from here going to find anything for you. It's your homework, you should do it.
"You won't be learn anything, if you expect others do your work for you".

You can try something on your own at first and when you stuck anywhere, anyone from here would do his/her best to help you out. But don't directly ask for the source code.

Read the Code Project Quick Answers FAQ[^] first :)

Kasthuri Gunabalasingam 21-Nov-15 11:40am
This is not a homework.. I'm doing a c# based project. this is require for to do a task!
PIEBALDconsult 21-Nov-15 13:57pm
And yet I think someone asked the same question a few months ago.
Kasthuri Gunabalasingam 21-Nov-15 14:11pm
aw..but I didn't check that
Rate this:
Please Sign up or sign in to vote.

Solution 2

How would you do it manually?

If someone reads you a set of numbers you would probably write them down one by one on a paper.
For the minimum number you would start with a very big number and write to the side, the saved min value.
For every new number you compare if it is smaller than the saved min value and if it is you scratch the old min value out and replace it with the new.
Unless it is -1, then you just ignore it and continue.

That's about it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100