Thursday 21 February 2013

C++ program to find a umber prime or not using arrays

| |

 



 



#include<iostream>
#include<string>


using namespace std;
int main()
{
   
    int z, array[z], n,x,f;
cout<<"upto how many nos?"<<endl;
cin>>z;
    cout<<"Enter The Numbers"<<endl;
for(n=0;n<z;n++)     
    {cin>>x;
    array[n]=x;
}


for(n=0;n<z;n++)
{
                int  count=0;
f=array[n];


while(f!=0)
{
           if(array[n]%f==0)
           {count=1+count;}
           f=f-1;
           }
           if(count==2)
           {cout<<array[n]<<" is Prime"<<endl;}
           else
          { cout<<array[n]<<" is not prime"<<endl;}
          }
            
  system("pause");
return 0;
}
 

C++ program to find a umber prime or not using arrays


Related Posts Plugin for WordPress, Blogger...
Powered by Blogger.