Daftar Isi

Rabu, 15 Februari 2012

script c++ "FPB / GCD"

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

int FPB(int a ,int b)
{int t;
    while(b!=0)
    {t=b;
    b=a % b;
    a=t;}
    return (a);
}

void main(){
int a,b, fpb;

cout<<"mencari FPB\n\n";
cout<<"masukkan angka pertama = ";
cin>>a;
cout<<"masukkan angka kedua = ";
cin>>b;

fpb=FPB(a,b);
cout<<"\n"<<"hasil FPB = " <<fpb<<endl;   
getch();
}


<<HALAMAN UTAMA

Jumat, 03 Februari 2012

script c++ "obesitas"

#include <iostream.h>
#include <conio.h>
void main(){
    double a,b,c;
cout<<"apakah anda mengalami obesitas???";
a:;
cout<<"\n\nmasukkan berat badan (dalam kilogram) = ";
cin>>a;
cout<<"masukkan tinggi badan (dalam centimeter) = ";
cin>>b;

c=a/(b/100);

if(c<18.5)
{cout<<"berat badan di bawah normal"<<endl;
}
else if(c>18.5&&c<24.9)
{cout<<"berat badan normal"<<endl;
}
else if(c>25.5&&c<29.9)
{cout<<"berat badan hampir obesitas"<<endl;
}
else if(c>30.0&&c<34.9)
{cout<<"berat badan obesitas rendah"<<endl;
}
else if(c>35.0&&c<39.9)
{cout<<"berat badan obesitas menengah"<<endl;
}
else
{cout<<"berat badan obesitas parah"<<endl;
}

char d;
cout<<"\n\ncoba lagi?(y/n)";
cin>>d;
if(d=='y')
{goto a;
}

cout<<"terima kasih"<<endl;
getch();

}


<<HALAMAN UTAMA