fork download
  1. #include<stdio.h>
  2. int main(){
  3. int n = 10;
  4. int *Primeslist;
  5. Primeslist = Prime(n);
  6. for(int i =0; i<n; i++){
  7. printf("%d\t",Primeslist[i]);
  8. }
  9. return 0;
  10. }
  11. int* Prime(int n){
  12. int count = 0;
  13. int *arr = (int*)malloc(sizeof(int)*n);
  14. /* if(n <= 0){
  15.   return NULL;
  16.   }*/
  17. for(int i = 2;i <= n; i++){
  18. if(i == 2 || i == 3 || i == 5 || i == 7){
  19.  
  20. arr[count] = i;
  21. count++;
  22. }
  23. if(i%2!=0 && i%3 != 0 && i%5!=0 && i%7!=0){
  24.  
  25. arr[count] = i;
  26. count++;
  27. }
  28.  
  29. }
  30. return arr;
  31. }
  32.  
Compilation error #stdin compilation error #stdout 0s 9432KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:5:16: warning: implicit declaration of function ‘Prime’ [-Wimplicit-function-declaration]
   Primeslist = Prime(n);
                ^~~~~
prog.c:5:14: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
   Primeslist = Prime(n);
              ^
prog.c: At top level:
prog.c:11:6: error: conflicting types for ‘Prime’
 int* Prime(int n){
      ^~~~~
prog.c:5:16: note: previous implicit declaration of ‘Prime’ was here
   Primeslist = Prime(n);
                ^~~~~
prog.c: In function ‘Prime’:
prog.c:13:20: warning: implicit declaration of function ‘malloc’ [-Wimplicit-function-declaration]
   int *arr = (int*)malloc(sizeof(int)*n);
                    ^~~~~~
prog.c:13:20: warning: incompatible implicit declaration of built-in function ‘malloc’
prog.c:13:20: note: include ‘<stdlib.h>’ or provide a declaration of ‘malloc’
stdout
Standard output is empty