deklarasi
int panjang,lebar,keliling
begin
panjang ← input
lebar ← input
begin
keliling ← 2*(panjang+lebar)
end
end
1. Python
# Keliling program in Python
print "menghitungkelilingpersegipanjang"
p = int (input("Masukkanpanjang :"))
l = int (input("Masukkanlebar :"))
k=2*(p+l)
print "kelilingpersegipanjang :",k
2. Pascal
Program Keliling(output);
VAR p,l,k: integer;
begin
writeln('Menghitungkelilingpersegipanjang');
write('MasukkanPanjang :');readln(p);
write('MasukkanLebar :');readln(l);
k := 2*(p+l);
writeln('keliling : ',k);
end.
3. Java
import java.util.Scanner;
public class kelilingPersegiPanjang{
public static void
main(String[]args){
intpanjang,lebar,keliling;
Scanner S = new
Scanner (System.in);
System.out.print("
MenghitungKelilingPersegiPanjang");
System.out.print("masukanpanjang = ");
panjang=S.nextInt();
System.out.print("masukanlebar = ");
lebar=S.nextInt();
keliling=2*(panjang+lebar);
System.out.println("kelilingpersegipanjangadalah = "+keliling);
}
}
4. C++
#include <iostream>
using namespace std;
intmain()
{
intp,l,k;
cout<<"MenghitungKelilingPersegiPanjang
"<<endl;
cout<<"MasukkanPanjang : ";
cin>>p;
cout<<endl;
cout<<"MasukkanLebar : ";
cin>>l;
cout<<endl;
k=2*(p+l);
cout<<"KelilingPersegiPanjang : "<<k;
cout<<endl;
return 0;
}
5. Ruby
#Keliling Program in Ruby
Print "MenghitungKelilingPersegiPanjang"
puts "MasukkanPanjang : "
p=gets.to_i
puts "MasukkanLebar : "
l=gets.to_i
print "KelilingPersegiPanjang : ",k.to_i
6. Perl
#
# KelilingPersegiPanjang Program in Perl
#
print "MenghitungKelilingPersegiPanjang\n";
print "MasukkanPanjang : ";
$panjang = <STDIN>;
chop($panjang);
print "MasukkanLebar : ";
$lebar = <STDIN>;
chop($lebar);
$keliling=2*($panjang + $lebar);
print "KelilingPersegiPanjang : $keliling\n";
7. GO
package main
import "fmt"
funcmain() {
var( p,l,kint)
fmt.Printf("MenghitungKelilingPersegiPanjang")
fmt.Printf("MasukkanPanjang : ")
fmt.Scanf("%d",&p)
fmt.Printf("MasukkanLebar : ")
fmt.Scanf("%d",&l)
k:= 2*(p+l)
fmt.Printf("KelilingPersegiPanjang : ",k)
}
8. FORTRAN
program KELILING
Real p,l, k
Print *,' Masukkanpanjang :'
Read *,p
Print *,' Masukkanlebar :'
Read *,l
k=2*(p+l)
print *, k
end program KELILING
------------------------
Anggota Kelompok:1. Agus Saputra (D1041141049)
2. Rangga Ramadhan (D1041141017)
3. Yulizar Pribadi (D1041141057)
4. Andhika Firmanto (D1041141053)
5. Ahmad Rafi'i (D1041141009)
6. Endi Tri Sukarta (D1041141077)
No comments:
Post a Comment