Abelsor

Semana 5 - Ejercicio 1

Mar 7th, 2022 (edited)
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. /*
  2.                             Semana 5 - Ejercicio 1
  3.     Escriba una función valide un numero entro y positivo.
  4. */
  5. #include<iostream>
  6.  
  7. using namespace std;
  8.  
  9. int validar(float);
  10.  
  11. int main()
  12. {
  13.     float num;
  14.  
  15.     cout<<validar(num)<<endl;;
  16.    
  17. }    
  18.  
  19. int validar(float n)
  20. {
  21.     do{
  22.         cout<<"Ingrese un numero entero y positivo: ";
  23.         cin>>n;
  24.     }  
  25.     while(int(n)!=n or n<0);
  26.    
  27.     return n;
  28. }
Add Comment
Please, Sign In to add comment