473,397 Members | 2,077 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Comparing numbers and determing the biggest.

Hey guys! 1st time poster here. Got a quick question. I'm just
beginning my journey into csharp and am developing a win32 app that
will retrieve a given useres account pull raw data from a db and
display that info. One of the things i need t odo is look at 7 entries
and compare those and then decide which is biggest and display that.
I am stuck. Can anyone help me out. I'm in no way asking for someone to

do this and me strip the code i would just like some very guided
directon. Any productive response would be awesome.

Nov 30 '05 #1
3 2675
Not sure if there more to your problem that what a simple algorithm might
solve, but here is something that might work. I just threw it together and
so I am not sure if it will work.

public int findLargest( params int[] numSet ){
int largestFound = numSet[0];

// This can be optimized so that first element is not eval since it was
initialized above.
foreach( int num in numSet ){
largestFound = Math.Max(largestFound, num);
}

return largestFound;
}
"esparkman" <ev***********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hey guys! 1st time poster here. Got a quick question. I'm just
beginning my journey into csharp and am developing a win32 app that
will retrieve a given useres account pull raw data from a db and
display that info. One of the things i need t odo is look at 7 entries
and compare those and then decide which is biggest and display that.
I am stuck. Can anyone help me out. I'm in no way asking for someone to

do this and me strip the code i would just like some very guided
directon. Any productive response would be awesome.

Nov 30 '05 #2
raj
this is a simple approach
i will write psudocode and hope that u can figure it all out
its extremely easy

variable currentNum = 0
variable largestFound = 0

take the very first # assign it to currentNum

while(we have more numbers)
{

if currentNum > largestFound
largestFound = currentNum
currentNum = read next number

}

"esparkman" <ev***********@gmail.com> wrote in message
news:11**********************@g14g2000cwa.googlegr oups.com...
Hey guys! 1st time poster here. Got a quick question. I'm just
beginning my journey into csharp and am developing a win32 app that
will retrieve a given useres account pull raw data from a db and
display that info. One of the things i need t odo is look at 7 entries
and compare those and then decide which is biggest and display that.
I am stuck. Can anyone help me out. I'm in no way asking for someone to

do this and me strip the code i would just like some very guided
directon. Any productive response would be awesome.

Nov 30 '05 #3
Thanks! Raj you is the man!

That is a much simpler approach.

Nov 30 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: lallous | last post by:
Hello, This code works fine when 'size' is less than 32768 however when size is bigger this function never returns. Can't find out why?! If I break into the code I can see that 'i' is 32768.......
11
by: John | last post by:
Hi, I encountered a strange problem while debugging C code for a Windows-based application in LabWindows CVI V5.5, which led me to write the test code below. I tried this code with a different...
89
by: purifier | last post by:
The problem is to write a program in 'C' to find the greatest of 2 given numbers... Easy? huh here's the catch do not use 'if' or any conditional statements if u want it to be a little more...
45
by: bobalong | last post by:
Hi I'm have some problem understanding how JS numbers are represented internally. Take this code for an example of weirdness: var biggest = Number.MAX_VALUE; var smaller = Number.MAX_VALUE...
30
by: vim | last post by:
hi How to find biggest of three numbers without comaprimg numbers
5
by: soeren | last post by:
Hello, two days ago I stumbled across a very strange problem that came up when we were printing tiny double numbers as strings and trying to read them on another place. This is part of an object...
2
by: Pugi! | last post by:
hi, I am using this code for checking wether a value (form input) is an integer and wether it is smaller than a given maximum and greater then a given minimum value: function...
27
by: Thomas Kowalski | last post by:
Hi everyone, To determine equality of two doubles a and b the following is often done: bool isEqual ( double a, double b ) { return ( fabs (a-b) < THRESHOLD ); } But this a approach usually...
5
by: saneman | last post by:
I have a function: int F(double a) { if (a = =1.0) { return 22; } return 44; }
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.