prime number

 #include <stdio.h>


int main()
{
    int i, n;
    printf("Enter a number to check:\n");
    scanf("%d", &n);
    for (i = 2; i < n; i++)
    {
        if (n % i != 0)
        {
            printf("The number is a prime number\n");
            break;
        }
        else
        {
            printf("The number is not a prime number\n");
            break;
        }
    }

    return 0;
}

Comments

Popular posts from this blog

snake game Version-2 (using random number)

allocating dynamic memory using calloc

store a table in dynamic array and then change the size of array dynamically to store more numbers