fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. #define N 300
  5.  
  6. //------
  7. #define BOOL int
  8. #define FALSE 0
  9. #define TRUE 1
  10.  
  11. void displayPrime (BOOL checkPrime);
  12. BOOL checkPrime (int num);
  13.  
  14. main()
  15. {
  16. BOOL is_prime[N+1];
  17.  
  18. displayPrime(is_prime);
  19.  
  20. getchar();
  21. }
  22.  
  23. void displayPrime (BOOL check)
  24. {
  25. int I;
  26.  
  27. for(I=1; I<N; I++)
  28. {
  29. checkPrime(is_prime[I]);
  30. if(is_prime[I]==TRUE)
  31. {
  32. printf("%d\n", I);
  33. }
  34. else if(is_prime[I]==FALSE)
  35. {
  36. printf("");
  37. }
  38. }
  39. }
  40.  
  41. BOOL checkPrime (int num)
  42. {
  43. int num;
  44.  
  45. is_prime[1]=FALSE;
  46. for(I=2; I<=sqrt(N); I++)
  47. {
  48. for(num=I; num<=N/num; num=num*I)
  49. {
  50. is_prime[num]=FALSE;
  51. }
  52. return(is_prime[I]);
  53. }
  54.  
  55. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:14:1: warning: return type defaults to ‘int’ [-Wreturn-type]
prog.c: In function ‘main’:
prog.c:18:6: warning: passing argument 1 of ‘displayPrime’ makes integer from pointer without a cast [enabled by default]
prog.c:11:6: note: expected ‘int’ but argument is of type ‘int *’
prog.c: In function ‘displayPrime’:
prog.c:29:26: error: ‘is_prime’ undeclared (first use in this function)
prog.c:29:26: note: each undeclared identifier is reported only once for each function it appears in
prog.c:36:23: warning: zero-length gnu_printf format string [-Wformat-zero-length]
prog.c: In function ‘checkPrime’:
prog.c:43:10: error: ‘num’ redeclared as different kind of symbol
prog.c:41:22: note: previous definition of ‘num’ was here
prog.c:45:6: error: ‘is_prime’ undeclared (first use in this function)
prog.c:46:10: error: ‘I’ undeclared (first use in this function)
prog.c:55:1: warning: control reaches end of non-void function [-Wreturn-type]
prog.c: In function ‘main’:
prog.c:21:1: warning: control reaches end of non-void function [-Wreturn-type]
stdout
Standard output is empty