langkah-langkah:
1. Buka software aplikasi Dev C++ atau Codeblock
2. Klik Menu File, pilih New, pilih Project
3. Pilih Console Aplication, pilih GoS
4. Pilih C++, Next
5. Beri nama project, lalu Next, kemudian Finish
6. Kemudian ketikkan sintax seperti berikut:
#include <iostream>
#include <Conio.h>
#include <stdlib.h>
using namespace std;
int main()
{
menu:
int x=1, jumlah=1;
char hitung;
cout<<endl;
cout<<" =============================================="<<endl;
cout<<" | TUGAS |"<<endl;
cout<<" =============================================="<<endl;
cout<<" | Soal: Nilai Faktorial |"<<endl;
cout<<" | Misalkan: |"<<endl;
cout<<" | Input = 3 |"<<endl;
cout<<" | Output = 3 * 2 * 1 = 6 |"<<endl;
cout<<" =============================================="<<endl<<endl;
cout<<"Jawab:"<<endl<<endl;
cout<<"Input Nilai Batas = ";
cin>>x;
cout<<endl;
cout<<x<<"! ===> ";
jumlah =1;
for(int bil=x; bil>=1;bil--)
{
jumlah=jumlah*bil;
}
while(x>=1)
{
cout<<x;
x=x-1;
if (x>=1)
{
cout<<" * ";
}
else
{
cout<<" = ";
}
}
cout<<jumlah<<endl<<endl<<endl;
cout<<"Lakukan Perhitungan lagi (Y/N) : ";
cin>>hitung;
if (hitung == 'y')
{
system("cls");
goto menu;
}
else
{
cout<<endl;
cout<<" Terima Kasih"<<endl<<endl<<endl<<endl<<endl;
cout<<" Oleh: "<<endl;
cout<<" Desty Septyani "<<endl;
cout<<" Teknik Informatika "<<endl;
}
return 0;
}
Selesai
Semoga bermanfaat
No comments:
Post a Comment