Write a program in C to check whether a number is Prime Or Not. 👨👨👨👨

                                                       VS CODE



                                                Turbo C++


#include <stdio.h>

int main()
{
int n, i, c = 0;
printf("Enter any number :");
scanf("%d", &n);

for (i = 1; i <= n; i++)
{
if (n % i == 0)
{
c++;
}
}

if (c == 2)
{
printf("%d is a Prime number\n",n);
}
else
{
printf("%d is not a Prime number\n",n);
}
return 0;
}

Post a Comment

0 Comments