print number in words
// print in words
Console.WriteLine("Enter a number to check wheather It is polydrom or not");
int a = int.Parse(Console.ReadLine());
int j = 0;
int h = 0;
int k = 0;
for (int i = a; i != 0; i = i / 10)
{
j = 0;
j = i % 10;
if (a == i)
{
h = j * 10;
}
if (a != i)
{
k = h + j;
h = k * 10;
}
}
for (; k != 0; k = k / 10)
{
int s = k % 10;
switch (s)
{
case 0:
Console.Write("Zero ");
break;
case 1:
Console.Write("One ");
break;
case 2:
Console.Write("Two ");
break;
case 3:
Console.Write("Three ");
break;
case 4:
Console.Write("Four ");
break;
case 5:
Console.Write("Five ");
break;
case 6:
Console.Write("Six ");
break;
case 7:
Console.Write("Seven ");
break;
case 8:
Console.Write("Eight ");
break;
case 9:
Console.Write("Nine ");
break;
default:
Console.Write("Enter integer value only");
break;
}
}
Console.ReadLine();
No comments:
Post a Comment