Back to Home Page

/******************************************************************************
Problem: Write a program that allow to the user enter a integer number as input
and show the number in backswords as output. Your program should include
a loop that lets the user repeat this calculation until the user
says she or he is done.

Programmer: Guillermo Julca
Mercy College

View Output


******************************************************************************/

using System;

namespace NumberBackwords

{

/// <summary>

/// Summary description for Class1.

/// </summary>

class Class1

{

static void Main(string[] args)

{

//

// TODO: Add code to start application here

//

int number;

int Ninv;

int dig;

char ans;

do

{

Console.Write("Enter a Number : ");

number = Convert.ToInt32(Console.ReadLine());

Ninv = 0;

while (number != 0)

{

dig = number % 10;

number = number / 10;

Ninv = (10 * Ninv)+ dig;

}

Console.WriteLine("The number in backwords is : {0} ",Ninv);

Console.Write("Do you want to continue (Y/N) ? : ");

ans = Convert.ToChar(Console.ReadLine());

}while (ans =='Y' || ans =='y');

}

}

}

//************************************************************************************************************

View Output

Back to Home Page


 GJ   Guillermo Julca