Silakan cari dengan menggunakan menu Label di sisi kiri | Blogger |
Kamis, 17 November 2011

Program latihan Struktur Data Praktikum

0 komentar

Program saat praktikum struktur data 17/11/2011

//////////////////////////////////////////////// latihan fungsi

#include <iostream.h>
#include <conio.h>
float jumlah(float a,float b);
float kurang(float a,float b);
float kali(float a,float b);
float bagi(float a,float b);

main(){
float a,b;
cout<<"masukan nilai a : ";
cin>>a;
cout<<"masukan nilai b : ";
cin>>b;
cout<<endl;
cout<<"a+b : "<<jumlah(a,b)<<endl;
cout<<"a-b : "<<kurang(a,b)<<endl;
cout<<"a*b : "<<kali(a,b)<<endl;
cout<<"a/b : "<<bagi(a,b)<<endl;
getch();
}

float jumlah(float a, float b){
return(a+b);
}
float kurang(float a, float b){
return(a-b);
}
float kali(float a, float b){
return(a*b);
}
float bagi(float a, float b){
return(a/b);
}

/////////////////////////////////////////// membuat mobil yang di bagi 3

#include <iostream.h>
#include <conio.h>
void moa(){
cout<<"      _______          "<<endl;
cout<<"   __/       \\____     "<<endl;
}
void mob(){
cout<<"  |_______________|    "<<endl;
}
void mor(){
cout<<"    O          O       "<<endl;
cout<<"---------------------- "<<endl;
}
main(){
moa();
mob();
mor();
getch();
}

////////////////////////////////////////// program luas segitiga dengan fungsi

#include <iostream.h>
#include <conio.h>
float bla(float s,float t){
float l;
cout<<"luas segitiga : "<<s<<" * "<<t<<" / 2 : ";
l=(s*t)/2;
cout<<l<<endl;
return(l);
}
main(){
int a;
float b,c;
cout<<"mau di ulang berapa kali : ";cin>>a;
for(int i=0;i<a;i++){
cout<<endl<<endl<<"#################################"<<endl;
cout<<"masukan alas   : ";cin>>b;
cout<<"masukan tinggi : ";cin>>c;
cout<<endl;
bla(b,c);
getch();
}
}
 
Blog Tugas DwiAR | © 2011 Design by DheTemplate.com and Theme 2 Blog and edited by Dwi A R