Check prime number


Write a C program to check whether the number is prime or not.

						
 #include<stdio.h>
 #include<conio.h>

void main(){
  int n,i=2;

  printf("Enter a number\n");
  scanf("%d",&n);
  while(i<=n-1){
    if(n % i == 0){
        printf("Not a prime number");
        break;
    }
    i++;
 }
 if(i == n)
    printf(" prime number");
}

Output (case1):

Output






Output (case2):

Output