dik no2:
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int luas_persegipanjang(int panjang, int lebar){
int luas;
luas=panjang*lebar;
return(luas);
}
int main(int argc, char** argv) {
int p, l, hasil;
cout<<"masukkan panjang = "; cin>>p;
cout<<"masukkan lebar = "; cin>>l;
hasil=luas_persegipanjang(p,l);
cout<<"luas persegi panjang = "<<hasil;
return 0;
}
dik no4:
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
float volume(float r){
float Phi=3.14, vol;
vol=(float)(4*Phi*r*r*r)/3;
return(vol);
}
int main(int argc, char** argv) {
float a, hasil;
cout<<"masukkan jari-jari = "; cin>>a;
hasil=volume(a);
cout<<"volume lingkaran = "<<hasil;
return 0;
}
dik no6:
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
float luas_segitiga(float a, float t){
float luas;
luas=(a*t)/2;
return(luas);
}
int main(int argc, char** argv) {
int alas, tinggi;
float hasil;
cout<<"masukkan alas = "; cin>>alas;
cout<<"masukan tinggi = "; cin>>tinggi;
hasil=luas_segitiga(alas,tinggi);
cout<<"luas segitiga = "<<hasil;
return 0;
}
dik no8:
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int tinggi (int x, int y){
int t;
t=(x/y*2);
return (t);
}
int main(int argc, char** argv) {
int a=0, l=0, tin;
cout<<"Menghitung tinggi segitiga"<<endl;
cout<<"Masukkan Luas Segitiga = "; cin>>l;
cout<<"Masukkan Alas Segitiga = "; cin>>a;
tin=tinggi(l,a);
cout<<"Tinggi Segitiga = "<<tin;
return 0;
}
dik no10:
#include <iostream>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int faktorial(int x){
int i=1, f;
f=1;
while(i<=x){
f=f*i; i++;
} return (f);
}
int main(int argc, char** argv) {
int n, r, p, permutasi;
cout<<"Menghitung Permutasi "<<endl;
cout<<"Masukkan nilai n = "; cin>>n;
cout<<"Masukkan nilai r = "; cin>>r;
p=n-r;
permutasi=faktorial(n)/faktorial(p);
cout<<"Hasil Permutasi nPr = "<<permutasi;
return 0;
}
Tidak ada komentar:
Posting Komentar