Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Semana 4 - Ejercicio 11
- Dado un nΓΊmero n, imprimir en pantalla sus divisores.
- */
- #include<iostream>
- using namespace std;
- int main()
- {
- float n;
- do{
- cout<<"Ingrese un numero entero y positivo: ";
- cin>>n;
- }
- while(int(n)!=n or n<0);
- cout<<"Los divisores de "<<n<<" son: "<<endl;
- // Buscamos los divisores de 'n'
- for(int i=1 ; i<=n ; i++){
- if(int(n)%i==0) // Como 'n' es de tipo 'float', debemos trabajar con su parte entera para usar el operador '%'
- cout<<i<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement