(Header.h)
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
double NilaiFaktorial(double r);
double NilaiPersamaanKuadrat(double r);
==========================================================
(Source.cpp)
#include"header.h"
double NilaiFaktorial(double r)
{
int c = 0 , hasil = 1 ;
if( r <= 1 )
{
return ( 1 ) ;
}
else
{
for( c = 1 ; c <= r ; c++ )
{
hasil = hasil * c ;
}
return ( hasil ) ;
}
}
double NilaiPersamaanKuadrat(double r)
{
return r*r*r-r*r+3*r+5;
}
==========================================================
(Main.cpp)
#include"header.h"
void main()
{
int pil;
do{
cout<<endl;
cout<<endl;
cout<<"==MENU PROGRAM==";
cout<<endl;
cout<<"1.Hitung Nilai Faktorial";
cout<< endl;
cout<<"2.NILAI Persamaan Kuadrat";
cout<< endl;
cout<<"3.Exit";
cout<<endl;
double r=1;
cout<<"masukkan sebuah angka :";
cin>> r;
cout<<"pilih menu:";
cin>>pil;
system ("cls");
switch(pil)
{
case 1:
cout << "Nilai faktorial dari " << r << " adalah "<<NilaiFaktorial(r)<<endl<<"TEKAN ENTER"<<endl;
;getch();
break;
case 2:
cout <<"NIlai Persamaan Kuadrat (X^3-X^2+3X+5) dari= "<< r <<endl<<"Adalah:"
<<NilaiPersamaanKuadrat(r)<<endl<<"TEKAN ENTER"<<endl;
getch();
break;
}
}while(pil!=3);
}
#include<iostream.h>
#include<conio.h>
#include<stdlib.h>
double NilaiFaktorial(double r);
double NilaiPersamaanKuadrat(double r);
==========================================================
(Source.cpp)
#include"header.h"
double NilaiFaktorial(double r)
{
int c = 0 , hasil = 1 ;
if( r <= 1 )
{
return ( 1 ) ;
}
else
{
for( c = 1 ; c <= r ; c++ )
{
hasil = hasil * c ;
}
return ( hasil ) ;
}
}
double NilaiPersamaanKuadrat(double r)
{
return r*r*r-r*r+3*r+5;
}
==========================================================
(Main.cpp)
#include"header.h"
void main()
{
int pil;
do{
cout<<endl;
cout<<endl;
cout<<"==MENU PROGRAM==";
cout<<endl;
cout<<"1.Hitung Nilai Faktorial";
cout<< endl;
cout<<"2.NILAI Persamaan Kuadrat";
cout<< endl;
cout<<"3.Exit";
cout<<endl;
double r=1;
cout<<"masukkan sebuah angka :";
cin>> r;
cout<<"pilih menu:";
cin>>pil;
system ("cls");
switch(pil)
{
case 1:
cout << "Nilai faktorial dari " << r << " adalah "<<NilaiFaktorial(r)<<endl<<"TEKAN ENTER"<<endl;
;getch();
break;
case 2:
cout <<"NIlai Persamaan Kuadrat (X^3-X^2+3X+5) dari= "<< r <<endl<<"Adalah:"
<<NilaiPersamaanKuadrat(r)<<endl<<"TEKAN ENTER"<<endl;
getch();
break;
}
}while(pil!=3);
}
Komentar
Posting Komentar