0
While loop
2. Write a program to test wither the entered number is a prime number or not using the prime number dived only on 1 and itself.
1 Answer
0
#include<iostream>
using namespace std;
int main(){
int n , i ;
bool ok=true;
for(i=2;i<n;i++){
if(n%i==0){
ok=false;
}
}
if(ok==true){
cout<<"prime";
}else{
cout<<"non prime";
}
}