nBuat
algoritma dan program untuk menghitung konversi dari m ke cm dan inchi !
nAnalisis
:
ØInput
: misalkan m (mewakili meter)
ØProses
: 1
meter = 100 cm
Ø 1 inci = 2.54 cm
Ø cm = m *100
Ø inci
= m*100/ 2.54
ØOutput
: tulis (cm, inci)
n
#include <iostream>
#include <conio.h>
using namespace std;
main () {
int cm,m,km,a,b,c, d, i;
cout<<"konversi dari cm ke km,m,cm:"<<endl;
cout<<"masukan nilai cm:";
cin>>a;
km=a/100000;
b=a%100000;
m=b/100;
c=b%1000;
i=m*100/2.54;
cm=c;
cout<<endl<<endl;
cout<<"km= "<<a/100000<<endl<<endl;
cout<<"meter= "<<b/100<<endl<<endl;
cout<<"inchi= "<<(float)i<<endl<<endl;
cout<<"cm= "<<c<<endl<<endl;
getch ();
}
#include <conio.h>
using namespace std;
main () {
int cm,m,km,a,b,c, d, i;
cout<<"konversi dari cm ke km,m,cm:"<<endl;
cout<<"masukan nilai cm:";
cin>>a;
km=a/100000;
b=a%100000;
m=b/100;
c=b%1000;
i=m*100/2.54;
cm=c;
cout<<endl<<endl;
cout<<"km= "<<a/100000<<endl<<endl;
cout<<"meter= "<<b/100<<endl<<endl;
cout<<"inchi= "<<(float)i<<endl<<endl;
cout<<"cm= "<<c<<endl<<endl;
getch ();
}
Komentar
Posting Komentar