Uses wincrt ;
var N, i, Max, Min, Total : Integer ;
A : Array[1..100] of Integer ;
Average : Real ;
Begin
Writeln ('Berapa kali Anda ingin menulis angka?') ;
Readln (N) ;
writeln ;
Writeln ('Silahkan masukkan ke-',N,' bilangan tersebut') ;
For i:=1 to N do
Readln (A[i]) ;
Writeln ;
Max:=A[1] ;
Min:=A[1] ;
For i:=1 to N do
Begin
if A[i] > Max then
Max:=A[i] ;
if A[i] < Min then
Min:=A[i] ;
End ;
Total:=A[1] ;
For i:=2 to N do
Total:=(Total+A[i]) ;
Average:=Total/N ;
Writeln ('Nilai terbesar : ',Max) ;
Writeln ('Nilai terkecil : ',Min) ;
Writeln ('Rata-ratanya : ',Average:0:2) ;
End.
Langganan:
Posting Komentar (Atom)
0 Response to "Program pascal mencari nilai min dan max "
Posting Komentar