[C++] Numar prim - Tutoriale si exercitii - GAMELIFE România Jump to content

Recommended Posts

  • Members
Posted

Salut, in codul de mai jos o sa va arat cum aflati daca un numar este prim:

#include<iostream.h>
int n, ok, d;
void main()
{
cin>>n;
d=2; ok=1;
while(d<=n/2&&ok==1)
if(n%d==0)
ok=0;
else
d++;
if(ok==1)
cout<<„Prim”;
else
cout<<„Nu”;
}

 

  • Like 1

eyixmpi.png

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.


×
×
  • Create New...

Important Information