Computer Science, asked by uttamankur123, 8 months ago

after step 8.
step 9 display number is not prime.
step 10 end
plz explain this question or if possible suggest me a simple solution.
thank you​

Attachments:

Answers

Answered by Yamini1999
0

Answer:

A number which is only divisible by itself and 1 is known as prime number, for example: 5 is a prime number because it is only divisible by itself and 1

Step 1: Start

Step 2: Read number n

Step 3: Set f=0

Step 4: For i=2 to n-1

Step 5: If n mod 1=0 then

Step 6: Set f=1 and break

Step 7: Loop

Step 8: If f=0 then

print 'The given number is prime'

else

print 'The given number is not prime'

Step 9: Stop

Explanation:

#include<iostream>

using namespace std;

int main( )

{

int n,i,f=0;

cout<<"Enter the number ";

cin>>n;

for(i=2;i<n;i++)

{

if(n%i==0)

{

f=1;

break;

}

}

if(f==0)

cout<<"The given number is prime\n";

else

cout<<"The given number is not prime\n";

return 0;

}

Similar questions