fork download
  1. #include <stdio.h>
  2. #include <stdbool.h>
  3.  
  4. // Function to check if a number is prime
  5. bool isPrime(int num) {
  6. if (num <= 1) return false;
  7. for (int i = 2; i * i <= num; i++) {
  8. if (num % i == 0) return false;
  9. }
  10. return true;
  11. }
  12.  
  13. int main() {
  14. int numbers[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20};
  15. int size = sizeof(numbers) / sizeof(numbers[0]);
  16.  
  17. printf("Prime numbers in the list: ");
  18. for (int i = 0; i < size; i++) {
  19. if (isPrime(numbers[i])) {
  20. printf("%d ", numbers[i]);
  21. }
  22. }
  23. printf("\n");
  24.  
  25. return 0;
  26. }
Success #stdin #stdout #stderr 0.02s 6800KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
ERROR: /home/ktrJhh/prog:26:0: Syntax error: Unexpected end of file
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? EOF: exit