tutorials

 FIND PRimE NumBer IN C++
  1. #include
  2. #include
  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.        }






No comments:

Post a Comment