227,143pages on
this wiki
Add New Page
Discuss this page0 Share
Programa:       Unidad4Ejercicio02.cpp
Descripción:    Muestra un número al revés.
#include <iostream>
using namespace std;

int alreves(int n);

void main ()
        int num, rev;

        cout << "Introduzca un numero ";
        cin >> num;

        rev = alreves(num);

        cout << "En numero al reves es = ";
        cout << rev;


int alreves(int n)
        int d, res = 0;
                // Extraemos el último digito
                d = n % 10;
                // Agregamos el dígito al resultado
                res *= 10;
                res += d;
                // Acortamos el número en un dígito
                n /= 10;
        return res;

Ad blocker interference detected!

Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.