English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

7 answers

Input three numbers.
Declare a variable 'small'(stores the smallest number) and assume that small = number1
if(number2 small = number2;
if(number3 < small)
small = number3;
Print - "The smallest number is" small;

I hope you can convert this into a proper C++ program, I am not very good at algorithms.

2006-10-20 22:41:59 · answer #1 · answered by Anonymous · 1 1

Declare your set of 3 number as A, B and C, and Min as variables

To make sure that one number amongst 3 is the smallest you have to compare it to the other 2
Naming A is the smallest if and only if A so your code should be something like that
If A < B And A < C Then
Min =A
ElseIf B < A And B < C Then
Min = B
ElseIf C < B And C < A Then
Min = C
End If
(in vb syntax)

2006-10-21 00:02:12 · answer #2 · answered by Anonymous · 0 0

ermm.... I no longer an issue-unfastened programmer... so i will write in PASCAL langugage....... var a:array[a million..3] of integer; {that's the variable assertion} n,i,max:integer; initiate jointly as n<>3 do initiate inc(i); readln(a[i]); inc(n); end; {that's the enter section} for i:= a million to 3 do initiate if a[i]>max then max:=a[i]; {that's the looking algorithms} end; writeln(max); {that's the OUTPUT/PRINT section} end; wish it enables peace vixklen

2016-11-24 20:54:58 · answer #3 · answered by saragosa 4 · 0 0

It's dead easy in Python:

s = [1,12,5] # for example
s.sort()
s[0] # returns 1, the minimum value
s[-1] # returns 12, the maximum

2006-10-21 00:37:30 · answer #4 · answered by poorcocoboiboi 6 · 0 0

You could actually do this in one line of code using a couple ternary operators in Java or C#, or anything that supports ( ? : )

2006-10-21 01:54:36 · answer #5 · answered by Dr.Mr.Ed 5 · 0 0

let the three numbers are a,b,c.
"small" is avariable to hold smallest value.
if((a small= c;
else
{
if((b small=b;
if((c small=c;
}

2006-10-20 23:47:32 · answer #6 · answered by indian 2 · 2 0

hmmm smalles 3 digit number uhh how about.....000?

2006-10-20 22:40:19 · answer #7 · answered by sslender9 3 · 0 1

fedest.com, questions and answers