Write a C program to check whether a number is prime or not using the function.
#include
int main()
{
int num,res=0;
printf("ENTER A NUMBER:\n");
scanf("%d",&num);
res=prime(num);
if(res==0)
printf("\n%d is PRIME NUMBER",num);
else
printf("\n%d is not a PRIME NUMBER",num);
getch();
}
int prime(int n)
{
int i;
for(i=2;i<=n/2;i++)
{
if(n%i!=0)
continue;
else
return 1;
}
return 0;
}
WorldTimeTech provides Movie News, Troubleshooting, and Programming knowledge. Thank You...
Copyright © 2023 WorldTimeTech.com All Rights Reserved.