Anda di halaman 1dari 2

//Latihan Program C++ Pertama

//Contoh01.cpp
#include<iostream.h>
void main()
{
cout<<"Selamat Datang\nPada Mata Kuliah C++\n";
}
// \n untuk membuat enter
=======================================================
//Latihan Program C++ Kedua
//Contoh02.cpp
#include<iostream.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
//Definisikan Variabel
int bil1;
int bil2;
int jumlah;
//INPUT
cout<<"Masukkan Bilangan Pertama : ";
cin>>bil1;
cout<<"Masukkan Bilangan Kedua : ";
cin>>bil2;
//PROSES
jumlah=bil1+bil2;
//OUTPUT
cout<<"Hasil Penjumlahan Adalah : "<<jumlah<<endl;
return 0;
}
=========================================================
//Latihan Program C++ Ketiga
//Latihan.cpp
#include<iostream.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
//Definisikan Variabel
int r;
double luas;
//INPUT
cout<<"Masukkan Jari-jari : ";
cin>>r;
//PROSES
luas=3.14*r*r;
//OUTPUT
cout<<"Luas Lingkaran Adalah : "<<luas<<endl;
return 0;
}

========================================================
//Latihan Program C++ Ketiga
//Latihan.cpp
#include<iostream.h>
#include<stdlib.h>
int main(int argc, char *argv[])
{
//Definisikan Variabel
int C;
double R,F,K;
//INPUT
cout<<"Masukkan Suhu Derajat Celcius : ";
cin>>C;
//PROSES
R=4/5*C;
F=9/5*C+32;
K=C+273;
//OUTPUT
cout<<C <<" Celcius = "<<R <<" Reamur\n";
cout<<C <<" Celcius = "<<F <<" Farenheit\n";
cout<<C <<" Celcius = "<<K <<" Kelvin"<<endl;
return 0;
}