Menghitung Rata-rata dengan C++

Tuesday, March 29, 2011 8:01 AM by Computer and Programming
#include <iostream.h>
#include <conio.h>
#include <iomanip.h>

void hitung_rata_1(float nilai_1, float nilai_2, float nilai_3)
{int rata_1;
rata_1= nilai_1 + nilai_2 + nilai_3/3;
cout<<"hasil rata-rata 1 dalah: "<<setprecision (2) <<rata_1<<"\n";
return;}

void hitung_rata_2(float nilai_1, float nilai_2, float nilai_3)
{int rata_2;
rata_2= (float nilai_1, float nilai_2, float nilai_3)/3;
cout<<"hasil rata-rata 2 adalah: " <<setprecision (2)<< rata_2<<"\n";
return;}

main ()
{float nilai_1,nilai_2,nilai_3;
cout<<"\t"<<"__ hitung rata_1 dan rata_2 __"<<"\n"<<endl;
cout<<"masukan nilai 1: ";cin>>nilai_1;
cout<<"masukan niali 2: ";cin>>nilai_2;
cout<<"masukan nilai 3: ";cin>>nilai_3;

hitung_rata_1(nilai_1,nilai_2,nilai_3);
hitung_rata_2(nilai_1,nilai_2,nilai_3);
getch ();
return 0;}

0 Response to "Menghitung Rata-rata dengan C++"

Post a Comment