#include<stdio.h>
int count_factor(int n)
{
int i=1,con=0;
printf("\nThe factors are=");
while(i<=n)
{
if(n%i==0)
{
con++;
printf(" %d ",i);
}
i++;
}
return con;
}
void isprime(int n)
{
if(count_factor(n)==2)
printf("\n%d is a prime number\n");
else
printf("\n%d is a prime number\n");
}
main()
{
int num;
printf("\nEnter a number=");
scanf("%d",num);
printf("\nNumber of factors=",count_factor(num));
isprime(num);
}
int count_factor(int n)
{
int i=1,con=0;
printf("\nThe factors are=");
while(i<=n)
{
if(n%i==0)
{
con++;
printf(" %d ",i);
}
i++;
}
return con;
}
void isprime(int n)
{
if(count_factor(n)==2)
printf("\n%d is a prime number\n");
else
printf("\n%d is a prime number\n");
}
main()
{
int num;
printf("\nEnter a number=");
scanf("%d",num);
printf("\nNumber of factors=",count_factor(num));
isprime(num);
}
No comments:
Post a Comment