Program to Check Whether the given number is Prime or not
https://www.computersprofessor.com/2016/06/program-to-check-whether-given-number.html?m=0
#include<stdio.h>
#include<conio.h>
main ( )
{
int n, i = 1, c = 0;
printf (“enter a number”);
scanf(“%d”,&n);
while(i<=n)
{
if(n%i==0)
c=c+i;
}
if(c==2)
printf(“The given number is not a
prime number”);
else
printf (” The given number is prime ”);
getch();
}
Out Put:
Enter a number 13
The given number is prime
Enter a number 18
The given number is not a prime number
|