LUAS PERSEGI
Mata Kuliah Algoritma
Pemrograman 2
Dosen Pengampu
: Dr. Herry Sujaini ST, MT.
Kelompok
6 :
Nama :
Franciska Nuri Anggraini ( D1041141003)
Nama :
Rudy Hartono ( D1041141051)
Nama :
M. Dwi Etsa Putra ( D03112013)
Nama :
Merriana ( D03112041)
Nama :
Felicia Feliana Maharani ( D03112047)
PROGRAM STUDI TEKNIK INFORMATIKA
UNIVERSITAS TANJUNGPURA
PONTIANAK
2015
1. C++
using namespace std;
int main()
{
float
r;
double
luas;
cout
<< " masukkan r : ";
cin
>> r;
luas
= r * r;
cout
<< "\n luas = " <<
luas << endl;
cin.ignore();
cin.get();
return
0;
}
2. Fortran
program luaspersegi
real :: r,
luas
write (*,*)' masukkan r '
read (*,*) r
luas = r*r
write (*,*)' Luas = ',luas
stop
end program luaspersegi
3. Java
import java.util.Scanner;
public class luaspersegi
public
static void main(String []args){
System.out.println("masukkan r:");
Scanner
scanner = new Scanner(System.in);
double
r = scanner.nextDouble();
double
luas = r*r;
System.out.println("luasnya: "+luas);
}
}
4. Pascal
Program LuasPersegi (output);
var s : integer;
begin
write('Input S :'); readln(s);
l:=s*s;
writeln('output :',l);
end.
5. Perl
print "masukkan r ";
chomp ($r = <>);
$luas = ($r * $r);
print "r: $r\n luas: $luas";
6. Php
<head>
<title>luas persegi</title>
</head>
<body>
<h2>menghitung luas persegi</h2>
<form
action = "<?php echo $_SERVER['PHP_SELF']; ?>" method = "GET">
r: <input type = "text" name =
"r" size=4>
<br/>
<br>
<input type="hidden" name="calc" value
="yes"> <input type =
"submit" name = "Calculate"/> </form>
<?php if ($_GET['calc'] ==
"yes") {
$r = $_GET['r'];
$luas = $r*$r;
print
"<h3>luasnya $luas <p><h3>"; }
?>
</body>
</html>
7. Phyton
r = input('masukkan nilai r: ')
r = int(r)
r = r*r
print 'luas persegi tersebut adalah ' + str(r)
8. Ruby
def hitung(r)
result = r
* r
return
result
end
r = 0.0
luas = 0.0
print "masukkan r: "
r = gets.to_f
luas = hitung(r)
puts "luasnya #{luas}."
9. Vb.
Net
Module VBModule
Sub Main()
Dim R
As Integer
Console.Write("masukkan r: ")
R =
Console.ReadLine
Dim
Luas As Integer
Luas =
R*R
Console.WriteLine()
Console.WriteLine("Luasnya: {0}", Luas)
Console.ReadLine()
End Sub
End Module
No comments:
Post a Comment