Menghitung luas lingkaran

#include<iostream>
#include<conio>


void main()
{
double r,luas, kel, phi=3.14 ;


cout<<"mecari luas dan persegi panjang\n";
cout<<"-------------------------------\n";
cout<<"masukkan jari-jari = "; cin>>r;

cout<<endl;
luas=phi*r*r;
kel=2*phi*r;

cout<<"jadi luas lingkaran adalah    = "<<luas<<" m"<<endl;
cout<<"jadi keliling lingkaran       = "<<kel<<" m"<<endl;

getch();
}



Share:

Menghitung Aritmatika C++

#include<iostream>
#include<conio>

void main()
{
int a,b,c,d,e,f,g ;
cout<<"masukkan bilangan 1 = "; cin>>a;
cout<<"masukan bilagan 2   = "; cin>>b;
cout<<endl;
c=a+b;
d=a-b;
e=a*b;
f=a/b;
g=a%b;
cout <<" hasil penjumlahan = " <<c<<endl;
cout <<" hasil pengurangan = " <<d<<endl;
cout <<" hasil perkalian   = " <<e<<endl;
cout <<" hasil pembagian (div)  = " <<f<<endl;
cout <<" hasil pembagian (mod)  = " <<g<<endl;
getch();
}
Share:

Array dengan 5 elemen C++

#include<iostream.h>
#include<conio.h>
void main ()
{
int data [5] ;//array dengan 5 elemen bertipe integer
int elemen;
clrscr ();
//entri 5 data
for (elemen = 0 ;elemen <= 4;elemen ++)
{
cout << "Data ke " << elemen << ':';
cin >> data [elemen];
}
// tampilkan data setelah entri
for (elemen=0;elemen <= 4;elemen++)
{
cout << " Data ke " << elemen << ":" << data [elemen];
}
getch ();
}
Share:

Program kasir pom bensin C++

nama : lukman
Kelas : TID
NIm : 3095111217



#include<iostream.h>
#include<conio.h>
void main()
{
char jenis;
int jml,bayar,total1,total2,sisa;
cout<<"==========================================================";cout<<endl;
cout<<"==================Program Kasir Pom Bensin================";cout<<endl;
cout<<"==========================================================";cout<<endl;
cout<<"masukkan jenis transaksi(bensin=b,pertamax=p)=";cin>>jenis ;
cout<<"jumlah liter=";cin>>jml;
cout<<"masukkan uang bayar=";cin>>bayar;
if  (jenis == 'b')
{
total1=jml*4500;
sisa=bayar-total1;
cout<<"============================";cout<<endl;
cout<<"total bayar="<<total1;
cout<<endl;
cout<<"============================";cout<<endl;
cout<<"uang kembali="<<sisa;
}
else
{
total2=jml*6800;
sisa=bayar-total2;
cout<<"============================";cout<<endl;
cout<<"total bayar="<<total2;
cout<<endl;
cout<<"============================";cout<<endl;
cout<<"uang kembali="<<sisa;
}
getch();
}

Share:

Menampilkan data C++

#include<iostream.h>
#include<conio.h>
void main()
{
int data [10];                       //array dengan10
int elemen;
clrscr();

for (elemen=0;elemen<=9;elemen++)   //entri 10 data
{
cout<<"Data Ke-"<<elemen<<" :";cin>>data[elemen];
}
for (elemen=0;elemen<=9;elemen++)   //tampilkan data
{
cout<<"Data Ke-"<<elemen<<" :"<<data[elemen]<<"\n";
}
getch ();
}
Share:

Jumlah barang banyak sintak C++

buat program untuk menghitung jumlah barang dengan inputan:
1. harga barang
2. jumlah barang
proses :
diskon = 10% dari total pembayaran
output:
total bayar = total pembayaran-diskon

#include<conio.h>
#include<iostream.h>

void main()
{
int a,b;
float c,d;
cout<<"masukkan harga barang = ";cin>>a;
cout<<"masukkan jumlah barang = ";cin>>b;
c=(a*b)*0,1;
d=(a*b)- c;
cout<<"maka totalnya ="<<d<<endl;
getch();
}

============================================================
#include<conio.h>
#include<iostream.h>

struct hitung{
int a,b;
float c,d;
    };


void main()
{
hitung harga;
cout<<"masukkan harga barang = ";cin>>harga.a;
cout<<"masukkan jumlah barang = ";cin>>harga.b;
harga.c=(harga.a*harga.b)*0.1;
harga.d=(harga.a*harga.b) - harga.c;
cout<<"maka totalnya ="<<harga.d<<endl;
getch();
}

===========================================================
perulangan:for..
  do..while..
1. buat statement perulangan untuk menampilkan angka dari 1 sampai 10
2. buat statement perulangan untuk menampilkan angka genap

jawab:

vertikal

#include<conio.h>
#include<iostream.h>

void main()
{
for(int i=1;i<=10;i++)
{
cout<<i<<endl;
}
getch();
}

===============================================================
mendatar 
#include<conio.h>
#include<iostream.h>

void main()
{
for(int i=1;i<=10;i++)
{
cout<<i<<" ";
}
getch();
}
==============================================================
jawaban no 2 .

#include<conio.h>
#include<iostream.h>

void main()
{
for(int i=1;i<=10;i++)
{
if (i%2==0)
cout<<i<<" ";
}
getch();
}
===============================================================

hasil menjadi minus

#include<conio.h>
#include<iostream.h>

void main()
{
for(int i=1;i<=10;i++)
{
if (i%2==0)
cout<<-i<<" ";
}
getch();
}
Share:

Jenis kelamin C++

#include <iostream.h>
#include <conio.h>

void main()
{
int nim;
char jk,nama[25];
cout<<"Nama = ";cin>>nama;
cout<<"Nim = ";cin>>nim;
cout<<"Jenis kelamin JK = ";cin>>jk;

if (nim %2==0 && jk=='L' || 'l')
{cout<<"Kls A\n";}
else if(nim %2==1 && jk=='P' || 'p')
{cout<<"Kls B\n";}
else if (nim %2==0 && jk=='L' || 'l')
{cout<<"Kls = C";}
else if(nim %2==1 && jk=='P' || 'p')
{cout<<"Kls D";}

getch();
}
Share:

Gaji karyawan perhari C++

#include <iostream.h>
#include <conio.h>
#include <math.h>

int main()
{
char yes;
yes='y';
while(yes=='y')
{
cout<<"**********************************************************************"<<endl;

int a,manager,karyawan;
int gm = 200000,gk=100000;
int angka;
cout<<"1.gaji manager"<<endl;
cout<<"2.gaji karyawan"<<endl;
cout<<"3.keluar"<<endl;
cout<<"masukkan pilihan anda = ";cin>>a;
cout<<"masukkan hari masuk anda = ";cin>>angka;
cout<<"**********************************************************************"<<endl;
switch(a)
{
case 1 :
manager=gm*angka;
cout<<"jumlah gaji manager =Rp. "<<manager<<endl;
break;
case 2:
karyawan=gk*angka;
cout<<"jumlah gaji karyawan =Rp. "<<endl;
cout<<karyawan<<endl;
break;
defalt:
goto exit;
}
exit:
cout<<"**********************************************************************"<<endl<<endl;
cout<<"                 tekan enter untuk halaman selanjutnya"<<endl;
getch();
clrscr();
cout<<"mau input data lagi ?"<<endl;
cout<<"tekan (y/t) untuk kembali ke awal : ";cin>>yes;
clrscr();
}
cout<<"                    thank you                                              "<<endl;
getche();
}


Share:

Identifikasi angka C++

#include<iostream.h>
#include<conio.h>
int main ()
{
clrscr();
int a;
cout<<"Masukkan Bilangan Yang Ingin diidentifikasi = ";cin>>a;
if((a%2==0)&&(a>0)){
cout<<"Bilangan Tersebut Merupakan Bilangan Genap Positif";}
if((a%2==0)&&(a<0)){
cout<<"Bilangan Tersebut Merupakan Bilangan Genap Negatif";}
if((a%2!=0)&&(a>0)){
cout<<"Bilangan Tersebut Merupakan Bilangan Ganjil Positif";}
if((a%2!=0)&&(a<0)){
cout<<"Bilangan Tersebut Merupakan Bilangan Ganjil Negatif";}
if(a=0){
cout<<"Angka nol";}
getch();
}



Share:

Function Panggil C++

#include <iostream.h>
#include <conio.h>
void garis (); //prototype function
// main function
void main ()
{
clrscr();
garis (); //panggil function
cout << " NIM NAMA MAHASISWA " << endl;
garis (); // panggil function
cout << " 3095111044 Uyi Sekaring Jagad" << endl;
cout << " 3095111000 Lee Yong Hwa " << endl;
garis(); //panggil function
getch();
}

void garis () // detail function
{
int i;
for (i=0;i<=5;i++)
{
cout <<"==";
}cout <<endl;
}

Share:

https://fikiirawan.blogspot.com/

Blog Archive

Pages

Featured Post

Menghitung luas lingkaran

#include<iostream> #include<conio> void main() { double r,luas, kel, phi=3.14 ; cout<<"mecari luas...

Blog Archive