search prime number

Q. Write a C program to find whether a number is prime or not.
Definition of prime number:A prime number is one,which is divisible only by one or itself. And its must greater than 1.
And if number is not prime, it is called composite number and vice versa.


int main()
 int x,num;
 printf("Enter number : ");
      printf("Number is not prime!!");
    printf("Number is prime!!");
 return 0;

    output of above program :

Enter number : 7
Number is prime!!

Related Programs:

  1. Generate first n Prime number C program
  2. Print Prime Number 1 to 100 C program
  3. Flowchart for search prime number

1 comment:

  1. It is not needed to check up to num-1 you can check up to square root of num is enough which simplifies and efficient program