Menentukan Bilangan Prima dengan C++

ini merupakan program untuk menentukan bilangan prima menggunakan c++
silahkan temen temen pelajari  yak
#include <iostream>
using namespace std;
int prima(int x){
    int i,n,faktor;
    faktor=0;   
    for(i=1;i<=n;i++)
    if(n%i==0)
    faktor++;
    if(faktor==2)
    return true;
    else
    return false;
    }
int main(){
    int n;
    cout<<"Masukan bilangan n= ";
    cin>>n;
    prima(n);
    if(true){
    cout<<"bilangan "<<n<<" bilangan prima";}
    else{
    cout<<"bilangan "<<n<<" bukan bilangan prima";}
    cout<<endl;
    system("PAUSE");
    return 0;
}
Posted in c++

komentar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

calender lalu
April 2013
T W T F S S M
« Mar    
 1
2345678
9101112131415
16171819202122
23242526272829
30  

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

Information
081-917- 166-???
Lunch: 11am - 2pm
Dinner: M-Th 5pm - 11pm, Fri-Sat:5pm - 1am
%d bloggers like this: