TUGAS ALPRO
Nama :
Oktarisia
Kelas :
SI Reg A
NIM :
09031281520125
DO
WHILE
#include <iostream>
using
namespace std;
int
main()
{
int
jumlah, i;
char
nama[100];
cout<<"masukkan
jumlah:";
cin>>jumlah;
cout<<"masukkan
nama:";
cin>>nama;
i=1;
do
{
cout<<nama<<"\n";
i++;
}while
(i<=jumlah);
return
0;
}
WHILE
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
int
a,b;
cout<<"masukkan
batas angka:";
cin>>b;
a=1;
while(a<=b)
{
a++;
cout<<"selamat
datang\n";
}
return
0;
}
FOR
#include
<iostream>
using
namespace std;
int
main()
{
int a,b;
cout<<"masukkan batas
angka:";
cin>>b;
for (a=1;a<=b;a++)
{
cout<<a<<"";
cout<<"\n";
}
return
0;
}
FUNGSI
#include
"iostream"
using
namespace std;
int
jumlah (int a,int b);
int
main (){
cout<<"Penggunaan fungsi
\n";
int x,y,hasil;
cout<<"Masukkan Nilai x =
";
cin>>x;
cout<<"Masukkan
Nilai y = ";
cin>>y;
hasil= jumlah (x,y);
cout<<"Hasil x + y =
"<<hasil;
}
int
jumlah (int a,int b){
return
(a+b);
}
PROSEDUR
#include<iostream>
using
namespace std;
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;
}
int
main(){
volume_limas();
cout<<endl;
return
0;
}
No comments:
Post a Comment