Berikut listing code dari bilangan faktorial di c++ dengan n yang diinputkan ketika program sudah berjalan..
#include "iostream.h"
#include "conio.h"
void main ()
{
int agk; int i;
cout << "\n Mencari Faktorial Bilangan"<< endl << endl;
cout << "masukkan bilangan!!" << "\nn = ";
cin >> agk;
int nfak = 1;
for (i=1 ; i<=agk ; i++)
nfak=nfak*i;
{cout << agk << "! = " << nfak ;}
cout << "\n\n.....................selesai";
cin >> agk;
getch ();
}
//Just try this listing code in ur c++ program. If U have any question, just leave your message here..
#include "iostream.h"
#include "conio.h"
void main ()
{
int agk; int i;
cout << "\n Mencari Faktorial Bilangan"<< endl << endl;
cout << "masukkan bilangan!!" << "\nn = ";
cin >> agk;
int nfak = 1;
for (i=1 ; i<=agk ; i++)
nfak=nfak*i;
{cout << agk << "! = " << nfak ;}
cout << "\n\n.....................selesai";
cin >> agk;
getch ();
}
//Just try this listing code in ur c++ program. If U have any question, just leave your message here..
0 komentar:
Posting Komentar