Print Number input by user is a prime or not using C language
/*Value is prime number or nor*/
#include<stdio.h> //include header file
void main()
{
int a,p;
printf("enter the number");
scanf("%d",&p);
a=2;
while(a<=p-1)
{
if(p%a==0)
{
printf("its not a prime no. ");
break;
}
a++;
}// end of while loop
if(a==p)
{
printf("its a prime no.");
}
} //end of main
No comments:
Post a Comment