samedi 22 août 2015

prime numbers c++ with for loop and no booleans used

please i need some help with aprime numbers code - - note - - : with using for loop and not allowed any bool varibules

  #include <iostream>
  using namespace std ;
  int main()
  {
     int n ,x;
     cin>>n;
    for(int i=1;i<=n;i++)
    {
      cin>>x;
     for(int a=2;a<x;a++)
      {

            if(x%a==0||x==0||x==1)
            {
                cout<<x<<"not prime"<<endl;
           }
        else
            cout<<x<<"prime"<<endl;
       }


        } 


          return 0 ;
                  }

Aucun commentaire:

Enregistrer un commentaire