#include
using namespace std;
int main() {
int n ,i=2;
cout<<"enter a number ";
cin>>n;
while(i<n)
{
if(n%i==0)
{
cout<<"not prime";
break;
}
i++;
if(i==n)
{
cout<<"prime";
}
}
return 0;
}
#include
using namespace std;
int main() {
int n ,i=2;
cout<<"enter a number ";
cin>>n;
while(i<n)
{
if(n%i==0)
{
cout<<"not prime";
break;
}
i++;
if(i==n)
{
cout<<"prime";
}
}
return 0;
}
Don’t use such statements
Print output according to the questions sample output
Your output should exactly match with sample output
can you give me the code once that will be very helpful for me to understand
Modified Code
#include<iostream>
using namespace std;
int main() {
int n , i = 2;
// cout << "enter a number ";
cin >> n;
while (i < n)
{
if (n % i == 0)
{
cout << "Not Prime";
break;
}
i++;
if (i == n)
{
cout << "Prime";
}
}
return 0;
}
I hope you understand now
and all testcased are passed
@abhishekpandeybhu_da87a9e0d2c73079
kindly give your feedback from link below
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.