Blogroll

This is default featured post 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured post 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Rabu, 28 November 2012

prosedur,fungsi di pascal dan C++



Listing program prosedur pascal
program procedure1;
uses crt;
var
a,b,c,d:real;
procedure nilai;
begin
d:=((a*0.3)+(b*0.3)+(c*0.4));
write(d:2:2);
end;
begin
clrscr;
write('Masukan Nilai Tugas Anda : ');readln(a);
write('Masukan Nilai UTS Anda : ');readln(b);
write('Masukan Nilai UAS Anda : ');readln(c);
write('Nilai Anda : ');
nilai;
readln;
end.

Input program
Logika program
Setelah progrsm dijalankan kemudian program memanggil variable dalam bentuk bilangan real procedur nilai.prgram memulai.selanjutnya program akan cetak  'Masukan Nilai Tugas Anda : ');program meminta kita untuk memasukan nilai a.
write('Masukan Nilai UTS Anda : ');program akan meminta kita untuk memaasukan nilai b
write('Masukan Nilai UAS Anda : ');program akan meminta kita memasukan nilai c.
write('Nilai Anda : '); nilai akhirpun kan terbaca.







Output program

Listing program fungsi pascal
uses crt;
var x,y,z:real;
function pangkat(a,b:real):real;
begin
pangkat:=exp(ln(a)*b);
end;
begin
clrscr;
write('masukan basis yang akan dipangkatkan  =');
readln(x);
write('masukan pangkat  ');
readln(y);
writeln;
z:=pangkat(x,y);
writeln('nilai',x:0:2,'^',y:0:2,'adalah:',z:0:2);
readln;
end.
Input program
Output program

Listing  program prosedur C++
#include<iostream.h>
void volume_limas()
{
double p, l, t;
cout<<"Volume limas segi empat"<<endl;
cout<<"Masukkan panjang: ";
cin>>p;
cout<<"Masukkan lebar: ";
cin>>l;
cout<<"Masukkan tinggi: ";
cin>>t;
cout<<"Volume limas segi empat: "<<p*l*t/3<<endl;
}
void volume_kerucut()
{
double r, t;
cout<<"Volume kerucut"<<endl;
cout<<"Masukkan jari2: ";
cin>>r;
cout<<"Masukkan t: ";
cin>>t;
cout<<"Volume kerucut: "<<3.14*r*r*t/3<<endl;
}
void volume_bola()
{
double r;
cout<<"Volume bola"<<endl;
cout<<"Masukkan nilai r= ";
cin>>r;
cout<<"Volume bola= "<<4*3.14*r*r*r/3<<endl;
}
int main()
{
volume_limas();
volume_kerucut();
volume_bola();

return 0;





input program
Logika program
Setelah program selesai dibuat kemudian program kan memanggil library dalam bentuk double betipe data p,l,t. kemudian akan cetak  Volume limas segi empat <<"Masukkan panjang: "; kemudian program akan membaca nilai p. selanjutnya program akan cetak <<masukan nilai lebar,kemudian program akan memebaca nilai l.selanjutnya  program akan cetak lagi <<"Masukkan tinggi:.selanjutnya akan membaca nilai t. program akan cetak volume limas.
Program memulai lagi ,kemudian program akan memanggil var dalam tipe r,t.program akan cetak  cout<<"Volume kerucut"<<endl; cout<<"Masukkan jari2: ";program akn membaca nilai r dan t. program akan cetak Volume kerucut: "<<3.14*r*r*t/3
Program memulia lagi kemuian program kan memanggil librarydalam tipe r .kemudian program akan cetak <<"Volume bola"<<endl;
cout<<"Masukkan nilai r=. kemudian program akan membaca nilai r,kemudian akan cetak cout<<"Volume bola= "<<4*3.14*r*r*r/3<<endl;
program selesai.



Output program

Listing fungsi C++
#include <iostream.h>
void duplicate (int& a, int& b, int& c)
{
a*=2;
b*=2;
c*=2;
}
int main ()
{
int x=1, y=3, z=7;
duplicate (x, y, z);
cout << "x=" << x << ", y=" << y << ", z=" << z;
return 0;
}


Input program
Logika program
Setelah program selesai dibuat maka program memulai selanjutnya program kan memanggil duplikat dalam bentuk integer a,b,c . kemudian program akan melakukan deklerasi perhitungan. Selanjutnya program kan cetak cout << "x=" << x << ", y=" << y << ", z=" << z; program selesai.

Output program

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More