#include <stdio.h>
#include <conio.h>
#include <iostream>
int main()
{
int long kode,harga,jumlah;
float bayar,diskon,total;
cout<<"masukan kode barang [1/2]:";cin>>kode;
cout<<"masukan harga barang :";cin>>harga;
cout<<"masukan jumlah barang :";cin>>jumlah;
bayar=harga*jumlah;
if(bayar>=100000)
diskon=bayar*10/100;
else
diskon=0;
total=bayar-diskon;
cout<<"total bayar :"<<total;
getch();
return 0;
}
Flowchart
Di blog ini saya sharing tentang apapun, seperti tentang berbagai hal yang saya ingin share ke kalian terutama tentang tugas-tugas kelompok pra-kuliah saya yang berhubungan dengan sosial media, keep on reed my this blog guys:)
Senin, 21 Desember 2015
Menghitung Keliling Lingkaran Menggunakan C++ & Flowchart-nya
#include <stdio.h>
#include <conio.h>
#include <iostream>
int main()
{
char hitung;
float phi=3.14,r,keliling;
clrscr();
awal:
cout<<"iput nilai jari-jari :";cin>>r;
keliling=2*phi*r;
cout<<"keliling adalah :"<<keliling<<endl;
cout<<"hitung lagi [Y/N] :";cin>>hitung;
if(hitung=='Y'||hitung=='y')
goto awal;
else
goto akhir;
getch();
akhir:
return 0;
}
Flowchart
#include <conio.h>
#include <iostream>
int main()
{
char hitung;
float phi=3.14,r,keliling;
clrscr();
awal:
cout<<"iput nilai jari-jari :";cin>>r;
keliling=2*phi*r;
cout<<"keliling adalah :"<<keliling<<endl;
cout<<"hitung lagi [Y/N] :";cin>>hitung;
if(hitung=='Y'||hitung=='y')
goto awal;
else
goto akhir;
getch();
akhir:
return 0;
}
Flowchart
Contoh Flowchart & Script Pilihan Menu Makanan
#include <stdio.h>
#include <constrea.h>
main()
{
awal:
char pilihan,*menu,hitung;
clrscr();
cout<<"masukan pilihan[1/2/3] :";cin>>pilihan;
if(pilihan=='1')
menu="Burger";
else if(pilihan=='2')
menu="Spageti";
else if(pilihan=='3')
menu="Sosbak";
else
menu="pilihan salah";
cout<<"cetak menu :"<<menu;
cout<<endl<<endl;
cout<<"----------------------------------------\n";
cout<<"hitung lagi [Y/N] :";cin>>hitung;
if(hitung=='Y'||hitung=='y')
goto awal;
else
goto akhir;
getch();
akhir:
}
Flowchart
#include <constrea.h>
main()
{
awal:
char pilihan,*menu,hitung;
clrscr();
cout<<"masukan pilihan[1/2/3] :";cin>>pilihan;
if(pilihan=='1')
menu="Burger";
else if(pilihan=='2')
menu="Spageti";
else if(pilihan=='3')
menu="Sosbak";
else
menu="pilihan salah";
cout<<"cetak menu :"<<menu;
cout<<endl<<endl;
cout<<"----------------------------------------\n";
cout<<"hitung lagi [Y/N] :";cin>>hitung;
if(hitung=='Y'||hitung=='y')
goto awal;
else
goto akhir;
getch();
akhir:
}
Flowchart
Mencari Nilai Maksimum & Minimum pada Suatu Bilangan Dengan C++
#include <stdio.h>
#include <conio.h>
#include <iostream>
int main()
{
int i, n=10, max, min;
int data[10]={23,11,5,2,3,9,67,83,8,4};
cout<<"Diketahui data yang ada :";
for(i=0;i<10;i++)
{
cout<<data[i];
cout<<" ";
}
cout<<endl<<endl;
max=min=data[0];
for(i=0;i<n;)
{
if(data[i]>max)
{
max=data[i];
}
else if(data[i]<min)
{
min=data[i];
}
i++;
}
cout<<"Nilai maksimum dari data di atas adalah: "<<max<<endl<<endl;
cout<<"Nilai minimum dari data di atas adalah: "<<min;
getch();
}
#include <conio.h>
#include <iostream>
int main()
{
int i, n=10, max, min;
int data[10]={23,11,5,2,3,9,67,83,8,4};
cout<<"Diketahui data yang ada :";
for(i=0;i<10;i++)
{
cout<<data[i];
cout<<" ";
}
cout<<endl<<endl;
max=min=data[0];
for(i=0;i<n;)
{
if(data[i]>max)
{
max=data[i];
}
else if(data[i]<min)
{
min=data[i];
}
i++;
}
cout<<"Nilai maksimum dari data di atas adalah: "<<max<<endl<<endl;
cout<<"Nilai minimum dari data di atas adalah: "<<min;
getch();
}
Menjumlahkan dua buah matrix dengan C++
#include <iostream>
#include <stdio.h>
#include <conio.h>
int main()
{
int i, j;
typedef int MATRIX32[3][2];
MATRIX32 A, B, C;
cout<<"MATRIK A"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout<<"A["<<i<<"]["<<j<<"] : "; cin>>A[i][j];
}
}
cout<<endl;
cout<<"MATRIK B"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout<<"B["<<i<<"]["<<j<<"] : "; cin>>B[i][j];
}
}
cout<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
C[i][j] = A[i][j] + B[i][j];
}
}
cout<<"MATRIK C = A+B"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout<<"C["<<i<<"]["<<j<<"] : "<<C[i][j]<<endl;
}
}
return 0;
}
#include <stdio.h>
#include <conio.h>
int main()
{
int i, j;
typedef int MATRIX32[3][2];
MATRIX32 A, B, C;
cout<<"MATRIK A"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout<<"A["<<i<<"]["<<j<<"] : "; cin>>A[i][j];
}
}
cout<<endl;
cout<<"MATRIK B"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout<<"B["<<i<<"]["<<j<<"] : "; cin>>B[i][j];
}
}
cout<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
C[i][j] = A[i][j] + B[i][j];
}
}
cout<<"MATRIK C = A+B"<<endl;
for (i=0; i<3; i++)
{
for (j=0; j<2; j++)
{
cout<<"C["<<i<<"]["<<j<<"] : "<<C[i][j]<<endl;
}
}
return 0;
}
Belajar C++ Untuk Menghitung Luas Macam Persegi, Segitiga, Dan Bujursangkar
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
main()
{
float alas, tinggi, panjang, lebar, sisi;
cout<<"MENGHITUNG LUAS SETIGA"<<endl;
cout<<"===================================\n";
printf("Alas = ");scanf("%f",&alas);
printf("Tinggi = ");scanf("%f",&tinggi);
cout<<("Luas Segitiga Adalah = ");
cout<<alas * tinggi /2;
cout<<"\n\n"<<endl;
cout<<"MENGHITUNG LUAS PERSEGI PANJANG"<<endl;
cout<<"===================================\n";
printf("Panjang = ");scanf("%f",&panjang);
printf("Lebar = ");scanf("%f",&lebar);
cout<<("Luas Persegi Panjang Adalah = ");
cout<<panjang * lebar;
cout<<"\n\n"<<endl;
cout<<"MENGHITUNG LUAS BUJUR SANGKAR"<<endl;
cout<<"===================================\n";
printf("Sisi = ");scanf("%f",&sisi);
cout<<("Luas Bujur Sangkar Adalah = ");
cout<<sisi * sisi;
cout<<endl<<endl<<endl;
cout<<"Nama Kelompok : \n";
cout<<"===================================\n";
cout<<"KELAS 12.1C.27\n";
cout<<"===================================\n";
cout<<"NIM = 12150996\n";
cout<<"NAMA = CHINTYA DEWI\n";
cout<<"===================================\n";
cout<<"NIM = 12155512\n";
cout<<"NAMA = SUTINA\n";
cout<<"===================================\n";
cout<<"NIM = 12155514\n";
cout<<"NAMA = AYU NOTA\n";
cout<<"=====================================\n";
cout<<"NIM = 12155587 \n";
cout<<"NAMA = HANIF ALFIYANTO\n";
cout<<"====================================="<<endl;
getch();
}
Output >>
#include<iostream.h>
#include<conio.h>
main()
{
float alas, tinggi, panjang, lebar, sisi;
cout<<"MENGHITUNG LUAS SETIGA"<<endl;
cout<<"===================================\n";
printf("Alas = ");scanf("%f",&alas);
printf("Tinggi = ");scanf("%f",&tinggi);
cout<<("Luas Segitiga Adalah = ");
cout<<alas * tinggi /2;
cout<<"\n\n"<<endl;
cout<<"MENGHITUNG LUAS PERSEGI PANJANG"<<endl;
cout<<"===================================\n";
printf("Panjang = ");scanf("%f",&panjang);
printf("Lebar = ");scanf("%f",&lebar);
cout<<("Luas Persegi Panjang Adalah = ");
cout<<panjang * lebar;
cout<<"\n\n"<<endl;
cout<<"MENGHITUNG LUAS BUJUR SANGKAR"<<endl;
cout<<"===================================\n";
printf("Sisi = ");scanf("%f",&sisi);
cout<<("Luas Bujur Sangkar Adalah = ");
cout<<sisi * sisi;
cout<<endl<<endl<<endl;
cout<<"Nama Kelompok : \n";
cout<<"===================================\n";
cout<<"KELAS 12.1C.27\n";
cout<<"===================================\n";
cout<<"NIM = 12150996\n";
cout<<"NAMA = CHINTYA DEWI\n";
cout<<"===================================\n";
cout<<"NIM = 12155512\n";
cout<<"NAMA = SUTINA\n";
cout<<"===================================\n";
cout<<"NIM = 12155514\n";
cout<<"NAMA = AYU NOTA\n";
cout<<"=====================================\n";
cout<<"NIM = 12155587 \n";
cout<<"NAMA = HANIF ALFIYANTO\n";
cout<<"====================================="<<endl;
getch();
}
Output >>
Langganan:
Postingan (Atom)