Anda di halaman 1dari 11

# PROGRAM INOUT

C
C Program Ini Membaca Masukan Dan Keluaran Nama
C
CHARACTER NAME*20
PRINT*,'Tulislah Namamu, Hingga 20 Karakter'
PRINT *,NAME
END

PROGRAM JumlahDanRataRata
C
C Program Ini Membaca 3 Angka Dijumlahkan Dan Dirata-Ratakan
C
Real Angka1, Angka2, Angka3, Jumlah, Rerata
Integer N
N=3
Jumlah = 0.0
Print *,'Contoh Program Sederhana Penjumlahan Dan Rata-Rata'
Print *,'Oleh : Ngakan Putu Purnaditya'
Print *,'Magister Teknik Sipil, Universitas Indonesia'
Print *,'--------------------------------------------'
Print *,'Tulislah 3 Angka, Pisahkan Dengan Spasi Atau Koma'
Jumlah=Angka1+Angka2+Angka3
Rerata=Jumlah/N
Print *,'Total 3 Angka Tersebut

: ',Jumlah

## Print *,'Rata-Rata 3 Angka Tersebut : ',Rerata

End

program time
C Deklarasi
real ltyr, ltmin, dist, elapse
integer minute, second
C ltyr

C ltmin

C dist

## C elapse : time taken to travel a distance dist in minutes

C
C Algoritma
print *,'---------------------------------------------'
C
print *,'Input ltyr : '
C
ltmin=ltyr/(365.25*24*60)
print *,'Input dist : '
C
elapse=dist/ltmin
minute=elapse
second=(elapse-minute)*60
C
print *,'

'

print *,'

'

## print *,'Light Takes ',minute,' Minutes'

print *,'

',second,' Seconds'

print *,'

'

print *,'

'

print *,'

'

## print *,'Example For Ngakan Putu Purnaditya'

print *,'Water Resources Engineering in University of
Indonesia'
end

program rain
C Deklarasi
real rainfl, sum, averge
integer month
dimension rainfl(12)
C Algoritma
print*,'----------------------------------------------------'
print*,'Water Resources Engineering, University of Indonesia'
print*,'----------------------------------------------------'
print*,' '
print*,' '
print*,'Type in the rainfall values one per line'
do 10 month=1,12
10

continue
print*,' '
print*,' '
sum=0
do 20 month=1,12
sum=sum+rainfl(month)

20

continue
averge=sum/12
print*,'- Summary monthly rainfall was :',sum
print*,'- Average monthly rainfall was :',averge
end

C Deklarasi
real berat, jumlah, rerata
integer orang
dimension berat(10)
C Algoritma
print*,'----------------------------------------------------'
print*,'Water Resources Engineering, University of Indonesia'
print*,'----------------------------------------------------'
print*,' '
print*,' '
do 10 orang=1,10
10

continue
print*,' '
print*,' '
jumlah=0
do 20 orang=1,10
jumlah=jumlah+berat(orang)

20

continue
rerata=jumlah/10
print*,'- Jumlah berat orang-orang tersebut

:',jumlah

## print*,'- Rata-Rata berat orang-orang tersebut :',rerata

end

Program MenghitungGeometriSilinder
C Deklarasi
real volume, tinggi, diameter, keliling, LAlas,LSelimut
parameter (phi=3.14159)
C Algoritma
print*,'-------------------------------------------------------'
print*,'Oleh

## print*,'Magister Rekayasa Sumber Daya Air Universitas Indonesia'

print*,'Keterangan : Latihan Fortran'
print*,'-------------------------------------------------------'
write(*,10)
write(*,20)
LAlas = 0.25 * phi * diameter**2
keliling = phi * diameter
volume = LAlas * tinggi
LSelimut = (2 * LAlas)+(keliling * tinggi)
write(*,100) volume
write(*,200) LSelimut
10

11

format(BN,F8.2)

20

21

format(BN,F8.2)

100

200

## format(/,1x,' Luas Selimut Silinder Adalah = ',F10.2)

end

? ',\)

= ',F10.2)

C Deklarasi
integer I, N
real X, Jmlh, Rataan, Var, Varians, Stdev
C Algoritma Judul
dimension X(1000)
print*,'-----------------------------------------'
print*,'PROGRAM ANALISA STANDAR DEVIASI SEDERHANA'
print*,'MAGISTER TEKNIK SIPIL UNIV. INDONESIA'
print*,'-----------------------------------------'
C Algoritma Statement Program
C Algoritma Hitung Jumlah Data
write (*,10)
jmlh=0
do 5 I=1,N
write (*,20) I
5

jmlh=jmlh+X(I)
write (*,100) jmlh

## C Algoritma Hitung Rata-Rata

Rataan=jmlh/N
write (*,200) Rataan
C Algoritma Hitung Varians
Var=0
do 7 I=1,N
7

Var=(Var+(X(I)-Rataan)**2)/N
varians=Var**2
write (*,300) Varians

## C Algoritma Hitung Standar Deviasi

Stdev=Varians**0.5
write (*,400) Stdev
C Algoritma Formatting
10

N =',\)

11

format (BN,I4)

20

21

format (BN,F8.2)

100

: ',F8.2)

200

: ',F8.2)

300

: ',F8.2)

400

## format (//,1X,'Standar Deviasi Nilai Mahasiswa Adalah : ',F8.2)

End

ProgramSederhanaKonversiMeter
C Deklarasi
real meter, kilometer, feet, yard, mile, inchi
C Algoritma Judul
print*,'-----------------------------------------'
print*,'PROGRAM KONVERSI SATUAN METER SEDERHANA'
print*,'MAGISTER TEKNIK SIPIL UNIV. INDONESIA'
print*,'-----------------------------------------'
C Algoritma Statement
C Algoritma Masukan Nilai Meter
write(*,10)
write(*,12)
C Algoritma Hitungan Konversi
kilometer = meter*0.001

feet

= meter*3.28

yard

= meter*1.09

mile

= meter*0.00062

inchi

= meter*39.37

write(*,*)
write(*,20) kilometer
write(*,30) feet
write(*,40) yard
write(*,50) mile
write(*,60) inchi
C Algoritma Formatting
10

11

format(BN,F8.2)

12

20

## format(//,1X,'Dalam Kilometer Adalah = ',F8.2)

30

= ',F8.2)

40

= ',F8.2)

50

= ',F12.10)

60

= ',F8.2)

End

Program SederhanaPenjumlahanMatrik
C Deklarasi
real*4 A(50,50), B(50,50), C(50,50)
C Algoritma Judul
print*,'-----------------------------------------'
print*,'PROGRAM SEDERHANA PENJUMLAHAN MATRIK'
print*,'MAGISTER TEKNIK SIPIL UNIV. INDONESIA'
print*,'-----------------------------------------'
C Algortima Statement
C Algoritma Jumlah Baris Dan Kolom
write (*,'(1X,A,\)')'Jumlah Baris Matrik ? '
write (*,'(1X,A,\)')'Jumlah Kolom Matrik ? '
C Algoritma Data Matrik A dan B
write (*,*)
do 100 I=1,JBaris
do 100 J=1,JKolom
write(*,'(1X,''A('',I2,'' , '',I2,'') ? '',\)')I,J
100

write (*,*)
do 200 I=1,JBaris
do 200 J=1,JKolom
write(*,'(1X,''B('',I2,'' , '',I2,'') ? '',\)')I,J

200

## C Algoritma Matrik C, Penjumlahan Matrik A dan Matrik B

do 300 I=1,JBaris
do 300 J=1,JKolom
300

C(I,J)=A(I,J)+B(I,J)

## C Algoritma Pencetakan Data Matrik

write (*,'(/,1X,A)')'Data Matrik A :'
do 400 I=1,JBaris
400

write (*,'(1X,100(F9.2))')(A(I,J),J=1,JKolom)
write (*,'(/,1X,A)')'Data Matrik B :'
do 500 I=1,JBaris

500

write (*,'(1X,100(F9.2))')(B(I,J),J=1,JKolom)
write (*,'(/,1X,A)')'Hasil Jumlah Matrik A dan B,Matrik C :'
do 600 I=1,JBaris

600

write (*,'(1X,100(F9.2))')(C(I,J),J=1,JKolom)
end

### Dapatkan aplikasi gratis kami

Hak cipta © 2022 Scribd Inc.

### Dapatkan aplikasi gratis kami

Hak cipta © 2022 Scribd Inc.