Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
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.!
Posted
Updated 21-Nov-15 4:55am
v3
Comments
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.

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 :)

-KR
 
Share this answer
 
Comments
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
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.
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900