C program to check if in array are prime numbers

Hello i want to build program to check if numbers in array are prime
my code is

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <stdio.h>

int is_prime(int number)
{
  int i;
  for (i=2; i<number; i++){
    if (number % i == 0 ) return 0;
 
  }
 return 1;
}

int main()
{
  int i;
  while(scanf("%d", &i) > 0)
  {
    if (is_prime(i))
      printf("prime\n");
    else
      printf("NOT\n");
       
 


  }
  return 0;
}

Input is
1
2
3
4
10

For some reason program defines 1 as prime number

Output should look like
NOT
Prime
Prime
NOT
NOT

Now it look like
Prime
Prime
Prime
NOT
NOT

Thanks for help
Last edited on
You probably want to add special handling for inputs less than 2.
Topic archived. No new replies allowed.