write a c program for to check weather the given number is prime or not
/* c program for to check wether the given number is prime or not */
/* author:sai date:8-4-2015 */
#include<stdio.h>
int main()
{
int n,i,count=0;
printf("ENTER THE NUMBER TO CHECK PRIME OR NOT\n");
scanf("%d",&n);
for(i=2;i<n;i++)
if(n%i==0)
{
count++;
break;
}
if(count==0)
printf("prime number\n");
else
printf("not prime number\n");
}
output:
/* c program for to check wether the given number is prime or not */
/* author:sai date:8-4-2015 */
#include<stdio.h>
int main()
{
int n,i,count=0;
printf("ENTER THE NUMBER TO CHECK PRIME OR NOT\n");
scanf("%d",&n);
for(i=2;i<n;i++)
if(n%i==0)
{
count++;
break;
}
if(count==0)
printf("prime number\n");
else
printf("not prime number\n");
}
output:
No comments:
Post a Comment