Blogger Tips And Tricks|Latest Tips For Bloggers Free Backlinks

Thursday, 15 November 2012

Write a program to find the given number is prime or not using in C language examples?

Prime number,find prime number,given number is prime or not,prime number in C,find the given number is prime or not,write a program to prime number,prime number program,Write a program to find the given number is prime or not using in C program language,C prime number,find C prime number


 Find the Prime number

         If a number is prime,it is divisible only with one(1) and itself(given number) is called Prime number.

                 #include<stdio.h>
                  main()
                  {
                        int n,i,c = 0;

                        printf("Enter number\n");
                        scanf("%d",&n);

                           for(i = 1; i <= n; i++ )
                             {
                                    if(n%i == 0)
                                     c++;
                              }
                         if(c == 2)
                         printf("It is Prime number\n");
                         else
                          printf("It is not a Prime number\n");
                   }

              Output:
                         1.  Enter number
                               7
                           It is a prime number

                        2. Enter number
                                 4
                             It is not a Prime number
      

0 comments:

Post a Comment