lunes, 6 de junio de 2011

IMPLEMENTAR UN PROGRAMA QUE ME PERMITA VER POR PANTALLA EL ULTIMO DIGITO IMPAR

//IMPLEMENTAR UN PROGRAMA QUE ME PERMITA VER POR PANTALLA EL ULTIMO DIGITO IMPAR
#include <iostream.h>
#include <conio.h>
bool UltimoDigitoImpar(int);
int main()
{
    int num,i=1;
    do
    {
        system("CLS");
        cout<<"Ingrese un numero: ";
        cin>>num;
        if(UltimoDigitoImpar(num))
        {
          cout<<"Ultimo Digito es impar.. "<<endl;                         
        }
        i++;
        system("PAUSE");
    }while(i<=5);
}
bool UltimoDigitoImpar(int p)
{
  int r=0;
  while(p>=1)
  {
    r=p%10;
    p=p/10;
  }    
  if(r%2 !=0)
    return true;
  else
    return false;
}

No hay comentarios:

Publicar un comentario