Program kali ini hampir sama dengan program sebelumnya If bertingkat. Namun kali ini kita menggunakan prosedur. Yaitu program/perintah yang berada diluar program utama.
#include <iostream>
using namespace std;
void nilaiakhir(float uts, float uas, float rata)
{
float hasil;
uts = uts*35/100;
uas = uas*35/100;
rata = rata*30/100;
hasil = uts+uas+rata;
cout << "HASIL AKHIR : " << hasil;
}
int main ()
{
float uts,uas,rata;
cout << "INPUT UTS : "; cin >> uts;
cout << "INPUT UAS : "; cin >> uas;
cout << "INPUT RATA : "; cin >> rata;
nilaiakhir(uts,uas,rata);
return 0;
}
using namespace std;
void nilaiakhir(float uts, float uas, float rata)
{
float hasil;
uts = uts*35/100;
uas = uas*35/100;
rata = rata*30/100;
hasil = uts+uas+rata;
cout << "HASIL AKHIR : " << hasil;
}
int main ()
{
float uts,uas,rata;
cout << "INPUT UTS : "; cin >> uts;
cout << "INPUT UAS : "; cin >> uas;
cout << "INPUT RATA : "; cin >> rata;
nilaiakhir(uts,uas,rata);
return 0;
}
Semoga bermanfaat!
Thanks for reading & sharing RZDev: Belajar Programming!
0 comments:
Post a Comment