32-Write a C program to display whether number is prime or not (while-loop).

Program: 32

Write a C program to display whether number is prime or not (while-loop).

#include
#include
void main()
{
    int i, num;
   printf("Enter any number: ");
   scanf("%d", &num);
   for(i=2;i<num;i++)
    {
        if(num%i==0)
        {
            printf("Not a prime number.");
            break;
        }
        else
        {
            printf("Number is Prime");
            break;
       }
    }
getch();
}
Output
Enter any number: 123

Number is Prime

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.