Contoh Sederhana Program C++

Contoh Program C++


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream.h>
#include<conio.h>
using namespace std;
int main(){
float c,r,f;
cout<<“masukkan nilai celcius: “;
cin>>c;
r=c*0.8;
f=c*1.8+32;
cout<<“hasil konversi suhu dari “<<c<<” drajat celcius ke reamur= “<<r<<endl;
cout<<“hasil konversi suhu dari “<<c<<” drajat celcius ke fahrenheit= “<<f<<endl;
cout<<endl;
getch();
return 0;
}
2. Program menghitung kecepatan
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>
#include<conio.h>
using namespace std;
int main()
{
int s,t,v;
cout<<” Mencari nilai kecepatan dalam satuan km “<<endl;
cout<<endl;
cout<<“masukan jarak yang akan di tempuh: “;
cin>>s;
cout<<“Masukan waktu tempuh: “;
cin>> t;
v=(s/t) ;
cout<<“Kecepatan nya ialah: “<<v<< “km/jam” <<endl;
getch();
return 0;
}

loading...

Share this

Related Posts

Previous
Next Post »