Showing posts with label പ്രൈം നമ്പര്‍. Show all posts
Showing posts with label പ്രൈം നമ്പര്‍. Show all posts

Saturday, September 29, 2012

പ്രൈം നമ്പര്‍ കണ്ടെത്താം.

ഒരു സംഖ്യ പ്രൈം നമ്പര്‍ ആണോ എന്ന് കണ്ടെത്താനുള്ള പ്രോഗ്രാം.



    1.    #include<iostream.h>
     2.    #include<conio.h>
     3.    void main()
     4.    {
     5.     //clrscr();
     6.     int number,count=0;
     7.     cout<<"ENTER NUMBER TO CHECK IT IS PRIME OR NOT ";
     8.     cin>>number;
     9.        for(int a=1;a<=number;a++)
   10.            {
   11.             if(number%a==0)
   12.                {
   13.               count++;
   14.                }
   15.            }
   16.    if(count==2)
   17.      {
   18.       cout<<" PRIME NUMBER \n";
   19.      }
   20.    else
   21.      {
   22.       cout<<" NOT A PRIME NUMBER \n";
   23.      }
   24.    //getch();
   25.    }

Read more »