View Single Post
Old Nov 6th, 2004, 3:53 AM   #12
lostcauz
Hobbyist Programmer
 
Join Date: Nov 2004
Location: 1691 miles East of L.A.
Posts: 159
Rep Power: 5 lostcauz is on a distinguished road
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;
}
__________________
-- lostcauz

Stepped in what?...
Behind whose barn?...
I didn't even know they had a cow!
lostcauz is offline   Reply With Quote