Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- //Declaracion de funcion
- bool primo(int num);
- int main(){
- int num;
- cout<<"ingrese un numero: ";
- cin>>num;
- if(primo(num)){
- cout<<"verdadero";
- }else{
- cout<<"falso";
- }
- cout<<endl;
- system("pause");
- return 0;
- }
- //Defenicion de la funcion
- bool primo(int num){
- int i, contprimo=0;
- for (i = 1; i <= num; i++){
- if (num%i==0){
- contprimo++;
- }
- }
- if (contprimo == 2){
- return true;
- }else{
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment