// Project 4 IsPrime.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include <math.h>
#define TRUE 1
#define FALSE 0
void main(void)
{ void isprime ( int );
int x;
printf ( "Please enter one integer --> ");
scanf ( "%d", &x );
isprime( x );
printf ( "%d" , x);
}
int isprime(int k)
{ int i;
int p=0;
int r;
for (i=2;i<k;i++)
{ r = k % i;
if (r==0)
{
p++;
}
}
if ( (p==0) )// makes it prime
return TRUE;
else
return FALSE;
}
Could use help, thank you.
-Adot2the
This post has been edited by Adot2the: 04 May 2008 - 12:59 PM

New Topic/Question
Reply




MultiQuote








|