Program to Check Whether the given number is Prime or not

#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


Related

C Programs 7773274413292360986

Post a Comment

emo-but-icon

item