Pages

Subscribe:

Checking Prime Number : Program In C

A prime number is a integer number greater than 1 and which number can be  divided by 1 or itself .

Example :
2,3,5,7,11,13,17,19,23,29,31,37,41,43
Prime Number program In C :


#include<stdio.h>
#include<conio.h>
void main()
{
    char ch;
    do{
        int a,b,flag=0;

        clrscr();

        printf("\tEnter a no (1-2000):");
        scanf("%d",&a);


        if(a<1 && a>2000)
        {
            exit(0);
          }
            for(b=2;b<a;b++)
            {
                if(a%b==0 )
                {

                flag=1;
                 break;
                   }
            }


    if(flag==0)
      printf("\n\t<%d> is a prime no\n",a);
    else
    printf("\n\t<%d>  is not a prime no\n",a);

    printf("\n\tContinue(y/n):");
    ch=getch();
      }while(ch=='y'||ch=='Y');



}


Output :
Prime_number.png





If you have any Further Information and Quires about this Article don't hesitate to comment in comment box below.
                                                           AND

 If you like this article , like our Facebook like page and click  +1 to support 123techguide
comments powered by Disqus
 

Listed In

Bloggers - Meet Millions of Bloggers http://Link-exchange.comxa.com
Blog Search: The Source for Blogs Internet Blogs

Disclaimer

The contents in this blog are taken from various sources available over the internet, therefore we do not gurantee of it's accuracy, if you find any of the content in the blog is infringing it's copyright, please do email us on '123techguide@gmail.com' and we will make sure to remove the same from the blog at the earliest.