?rel=0&autoplay=1" width="560">

This is default featured slide 1 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 2 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 3 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 4 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

This is default featured slide 5 title

Go to Blogger edit html and find these sentences.Now replace these sentences with your own descriptions.This theme is Bloggerized by Lasantha Bandara - Premiumbloggertemplates.com.

Showing posts with label Tugas Mentor. Show all posts
Showing posts with label Tugas Mentor. Show all posts

Sunday, March 29, 2015

Tugas Mentor

Buatlah program faktorial menggunakan kelas dengan fungsi method, yaitu input, proses, output. Juga dengan sekuennya.

Jawab :

Sintak C++ :

#include <iostream>
using namespace std;
class faktorial
{
public:
int proses();
void output();
private:
int n,faktor;
};
int faktorial::proses()
{
cout<<"== MENGHITUNG ANGKA FAKTORIAL =="<<endl;
cout<<endl;
cout<<"Masukan Angka : ";cin>>n;
faktor=1;
if(n>0)
{
for(int i=1; i<=n; i++)
{
faktor*=i;
}}
else if(n=0)
{ faktor=1;
}
else
{ cout<<"Angka yg anda masukkan invalid/tidak dapat di proses";
}
return faktor;
}
void faktorial::output()
{ cout<<endl<<n<<"! "<<"adalah = "<<faktor;
}
int main()
{
faktorial angka;
angka.proses();
angka.output();
return 0;
}


Screenshootnya :




Raptor :