62. WAP to check if the given number is prime number or not

 #include<stdio.h>

void main()

{

        int num,i,c=0;

        printf("WAP to check if the given number is prime number or not\n");

        printf("Enter a number : ");

        scanf("%d",&num);

        for(i=1;i<=num;i++)

        {

                if((num%i)==0)

                        c++;

        }

        if(c==2)

                printf("Its a prime number\n");

        else

                printf("Its not a prime number\n");

 

}

Comments