You are on page 1of 12

TUGAS

ALGORITMA DAN PEMOGRAMAN 2

Denis Akbar
0651-13-121

VOLUME TABUNG

FUNGSI TANPA NILAI BALIK


ALGOTITMA :
Void tab_bung ();
{
int d,e;
float n;
cin>>d;
cin>>e;
n=3.14*d*d*e;
cout<<n;
}

PROGRAM :
#include<iostream.h>
void tab_bung();

void tab_bung()
{
int d,e;
float n;

cout<<"Masukan Nilai Jari - Jari : ";


cin>>d;
cout<<"Masukan Nilai Luas Tabung : ";

cin>>e;

n=3.14*d*d*e;

cout<<"Volume Tabungnnya Adalah : ";


cout<<n<<endl<<endl;
cout<<"
}

void main ()
{
tab_bung ();
}

PROGRAM RUNNING

| Denis Akbar | 0651 - 13 - 121 |";

FUNGSI DENGAN NILAI BALIK

ALGORITMA :

float hasil (int u, int n);


void main ()
{
int d,e;
float n;
cin>>d;
cin>>e;
float hasil (d,e)
cout<<n;
}
float hasil (int u, int n)
{
return (3.14*u*u*n);
}

PROGRAM :
#include<iostream.h>
float hasil (int u, int n);
void main ()
{
int d,e;
float n;
cout<<"
| Denis Akbar | 0651 - 13 - 121 |"<<endl<<endl;
cout<<"Masukan Nilai Jari - Jari : ";
cin>>d;
cout<<"Masukan Nilai Tinggi : ";
cin>>e;

n=hasil(d,e);
cout<<"Volume Tabungnnya Adalah : ";
cout<<n;
}
float hasil (int u, int n)
{
return (3.14*u*u*n);
}

PROGRAM RUNNING :

ARAY

ARAY 1 DIMENSI

ALGORITMA :

Int d[2][4]={5,6,7,8,8,4,4,7}
Int e[2][4]
For n=0 to 1 do
For s=0 to 3 do
e [n][s]=d[n][s]*4
end for s
end for n

PROGRAM :
#include <iostream.h>
void main ()
{
cout<<"

| Denis Akbar | 0651 - 13 - 121 |"<<endl<<endl;

int d[2][4]={5,6,7,8,8,4,4,7},e,n;
for (e=0;e<=1;e++)
{
for (n=0;n<=3;n++)
{
cout<<d[e][n]*4<<" ";
}
}
}

PROGRAM RUNNING :

ARAY 1 DIMENSI

ALGORITMA :
int d[3][3]={0,0,0,2,0,0,2,2,0};
int e,n,s, tampil;
e=0
tampil=0
For n=0 to 2
For s=0 to 2
if(d[n][s]-0
tampil++;
e= d[n][s];
End if
End for n
End for s
Print e
Print tampil

PROGRAM :
#include<iostream.h>
void main ()
{
int d[3][3]={0,0,0,2,0,0,2,2,0};
int e,n,s, tampil;
e=0;
tampil=0;
cout<<"

| Denis Akbar | 0651 - 13 - 121 |"<<endl<<endl;

cout<<"Matriks Pada Soal"<<endl;


for (n=0;n<=2;n++)

{
for (s=0;s<=2;s++)
{
if(d[n][s]-0)
{
tampil++;
}
e= d[n][s];
cout<<e<<" ";
}
cout<<endl;
}
cout<<endl;
cout<<"Pada Matriks Diatas Mempunyai Nilai 2 : ("<<tampil<<")";
}

PROGRAM RUNNING :

You might also like