June 3, 2023
Program to use whether a number is prime or not in C Language
#include <stdio.h>
#include <math.h>
int main()
{
int i, n;
printf("enter a number : ");
scanf("%d", &n);
for (i = 2; i <= sqrt(n); i++)
{
if (n % i == 0)
{
break;
}
}
if (i > sqrt(n))
{
printf("%d is prime\n", n);
}
else
{
printf("%d is not prime\n", n);
}
return 0;
}
output
enter a number :
23 is prime
by : Nadeem Khan
Quick Summary:
Program to use whether a number is prime or not in C Language copy #include <stdio.h> #include <math.h> int main() { int i, n; printf(“enter a number : “); scanf(“%d”, &n); for (i = 2; i <= sqrt(n); i++) { if (n % i == 0) { break; } } if (i > sqrt(n)) { […]