Analysis program:
Already know it primes?? A prime number (or a prime) is a natural number that has exactly two distinct natural number divisors: 1 and itself. For example, we input the number 3 it will be in the process with thisprogram that the results are excellent.
Algorithm:
1. Suppose this number is X.
2. number is even or odd.
3. If the numbers are completed (except 2) means not a prime number.
4. Numbers were only divisible by 1 and the number itself or not?
5. If not, then not a prime number.
6. If so, then the prime numbers.
Program :
[sourcecode language="css"]
#include <iostream.h>
class prima
{
public:
prima();
input();
proses();
private:
int bil, batas, x, i;
};
prima::prima()
{ cout<<"Menentukan bilangan prima atau bukan"<<endl<<endl;}
prima::input()
{ cout << "Masukkan bilangan : ";
cin >> x;
cout<<endl;}
prima::proses(){
batas = 0;
for ( i=1; i<=bil; i++)
{
if (bil%i==0 && x !=0)
batas++; }
if (batas==2){
cout << "Termasuk bilangan prima \n"; }
else {
cout << "Bukan bilangan prima \n";}
}
int main()
{
prima bilangan;
bilangan.input();
bilangan.proses();
}
[/sourcecode]
Friday, 22 April 2011
Subscribe to:
Post Comments (Atom)
Popular Posts
-
Nemu artikel bagus nih tentang agama. Gak ada salahnya saya posting, apalagi sebelum bulan ramadhan ini. TAKHALLI sesungguhnya berunt...
-
#include <cstdlib> #include <iostream> using namespace std; int floor(double x){ int a; ...
-
KATA PENGANTAR
Blog Archive
-
▼
2011
(95)
-
▼
Apr
(19)
- Menentukan Bilangan Prima
- Membuat Kalkulator sederhana
- Menghitung Deret 1-1/2+1/3-1/4+..+1/n
- Merubah Nilai ke Huruf
- Specifies the Day of the input numbers
- Algoritma dan Program menentukan Tahun Kabisat
- Algoritma dan Program Mencari luas Lingkaran dan v...
- Contoh Form dan Frame diHTML
- Mencari KPK c++
- Menentukan tahun Kabisat ( Jeliot )
- Menentukan FPB
- Program Sederhana menentukan angka habis di bagi 3...
- Menentukan Persamaan Kuadrat (Akar Imajiner)
- Membuat tabel dan hyperlink di HTML
- PILIHAN SULIT
- Mencari Luas Lingkaran dan Volum Bola ( versi Jeli...
- Netbook Saya
- Program C++ Mengisi BBM
- Kiat Berbisnis Dengan Keamanan Sistem Handal Melal...
-
▼
Apr
(19)
|
[close]
Powered by Blogger.
0 komentar:
Post a Comment