Recent Posts

9-latest-250px-course

Write a C program to Check whether a given number is a prime or not

Write a C program to Check whether a given number is a prime or not


Program:-     

#include<stdio.h>

int main()

{

int n,i;

printf(“\nEnter the number : “);

scanf(“%d”,&n);

for(i = 2; i <= n/2; i++)

{

if(n % i ==0)

{

break;

}

}

if(i > n/2)

printf(“\n%d is a Prime Number\n”,n);

else

printf(“\n%d is not a Prime Number\n”, n);

return 0;

}

Output:-

....
SHARE

Milan Tomic

Hi. I’m Designer of Blog Magic. I’m CEO/Founder of ThemeXpose. I’m Creative Art Director, Web Designer, UI/UX Designer, Interaction Designer, Industrial Designer, Web Developer, Business Enthusiast, StartUp Enthusiast, Speaker, Writer and Photographer. Inspired to make things looks better.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment