Here we written code for to check given number is Prime or Not.
For improvement of your coding skills we give some tasks along this. If you solve this tasks and send to our email (firstname.lastname@example.org) with your details. we will display your details(like Name, City, college, photo) in our site.
Task : Write a c program to print nth prime number.
Write a C Program to Find Whether the Given number is Prime or Not.
int a,i,count=0; //’a’ is user defined number, ‘i’ for iteratiions, ‘count’ for counting factor of given number.
printf(“Enter a number :”);
if(a%i==0) //check the iteration value is factor of given number or not.
if(count==2) //Every prime number should have only two factors.
printf(“Given number is PRIME number\n”);
printf(“Given number is Non-PRIME number\n”);
i) Enter a number : 28541
Given number is PRIME number
ii)Enter a number : 30857
Given number is Non-PRIME number
Back to the programs list.