Quote:
Originally posted by fwongmc@Nov 6 2004, 05:17 AM
It can't reply me for any answers.It even cannot be run.Can you tell me what errors do I make and how to Irect this errors?
|
I haven't coded much C in a while but
I noticed some obvious errors with your code so
I gave some hints here. Watch your syntax. I tried
keeping this in your writing style as best as I could.
gcc -o ptest ptest.c
#include <stdio.h>
int is_prime(int n){
int i,prime;
for (i=2;i<n;i++){
if(n%i==0){prime=0;}
if (n==2){prime=1;}
}
if(prime){printf("%d is a prime number",n);}
else{printf ("%d isn't a prime number",n);}
}
int main(){
int a;
printf ("Enter your input:");
scanf ("%d",&a);
is_prime(a);
return 0;
}