|
-
Aug 31st, 2007, 06:01 PM
#1
Re: Finding out which integer is smallest
What is even in the chapter? We can't really say anything before knowing that. It's probably just asking you to have some nested if's. Even perhaps something like:
C++ Code:
int smallest = a;
if (b < a)
smallest = b;
if (c < b)
smallest = c;
if (c < a)
smallest = c;
..etc.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 31st, 2007, 10:19 PM
#2
Thread Starter
Member
Re: Finding out which integer is smallest
Write a program that inputs three integers from the keyboards and prints the sum, average,
product, smallest and largest of these numbers.
anyone else?? I'm stuck on telling which number is smallest.
My questions might look stupid to others. After all I am still in the process of learning Visual Basic.
-
Sep 1st, 2007, 12:29 AM
#3
Re: Finding out which integer is smallest
Find the minimum of two values; then find the minimum of your selected minimum and the other value.
If you had a function MIN(a,b) which returned the lesser of two values:
Code:
int a, b, c;
min = MIN(a, b);
min = MIN(min, c);
// min is the minimum value.
your min function might do this:
Code:
if (a < b)
return a; // a is less than b
else
return b; // b is less than a OR a = b (they are both the 'min')
Hope this helps!
Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.
-
Sep 1st, 2007, 02:40 PM
#4
Thread Starter
Member
Re: Finding out which integer is smallest
 Originally Posted by sunburnt
Find the minimum of two values; then find the minimum of your selected minimum and the other value.
If you had a function MIN(a,b) which returned the lesser of two values:
Code:
int a, b, c;
min = MIN(a, b);
min = MIN(min, c);
// min is the minimum value.
your min function might do this:
Code:
if (a < b)
return a; // a is less than b
else
return b; // b is less than a OR a = b (they are both the 'min')
Hope this helps!
I'm srry I haven't gotten to that stuff yet and in the chapter it says i'm only suppose to use what I have learned so far. Is there like an equation or something to find out which of the numbers given is smallest?
My questions might look stupid to others. After all I am still in the process of learning Visual Basic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|