ex prog fungsi
#include<iostream.h>
#include<conio.h>
#define phi 3.14
float luas_lingkaran (float r)
{
float t;
t=phi*(r*r);
return(t);
}
float kel_lingkaran(float r)
{
float t;
t=2*phi*r;
return(t);
}
main()
{
float z,d,y;
cout<<"masukkan nilai jari-jari=";
cin>>y;
cout<<"Contoh pemograman fungsi"<<endl<<endl;
z=luas_lingkaran(y);
d=kel_lingkaran(y);
cout<<endl;
cout<<"Hasil luas lingkaran:"<<phi<<"*"<<y<<"*"<<y<<"="<<z<<endl;
cout<<"Hasil keliling lingkaran:2*"<<phi<<"*"<<y<<"="<<d<<endl;
getch();
}
Comments
Post a Comment