0% found this document useful (0 votes)
28 views

Program No 2

The program takes a number as input from the user and reverses it. It then iterates through each digit of the reversed number and prints the corresponding word (e.g. one, two, etc.) for each digit. This allows the user to see the input number written out as words from right to left.

Uploaded by

pooja
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Program No 2

The program takes a number as input from the user and reverses it. It then iterates through each digit of the reversed number and prints the corresponding word (e.g. one, two, etc.) for each digit. This allows the user to see the input number written out as words from right to left.

Uploaded by

pooja
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

PROGRAM NO.

2
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace prog2
{
class Program
{
static void Main(string[] args)
{
long num, i,k,rev=0;
Console.Write("Enter the number:"+" ");
num = int.Parse(Console.ReadLine());

for (i = num; num > 0;i++ )


{
k = num % 10;
rev = rev * 10 + k;
num = num / 10;
}
for (i = rev; rev >0; i++)
{
k = rev % 10;
switch (k)
{
case 1:
Console.Write("one");
Console.Write(" ");
break;
case 2:
Console.Write("two");
Console.Write(" ");
break;
case 3:
Console.Write("three");
Console.Write(" ");
break;
case 4:
Console.Write("four");
Console.Write(" ");
break;
case 5:
Console.Write("five");
Console.Write(" ");
break;
case 6:
Console.Write("six");
Console.Write(" ");
break;
case 7:
Console.Write("seven");
Console.Write(" ");
break;
case 8:
Console.Write("eight");
Console.Write(" ");
break;
case 9:
Console.Write("nine");
Console.Write(" ");
break;
}
rev = rev / 10;
}
}
}
}

Output of the Program:


Enter the number: 98485747

nine eight four eight five seven four seven

Press any key to continue . . .

You might also like