Numbers Postfix Program

static void Main(string[] args)
{
int no;
string con;
do
{
Console.WriteLine(“Enter No:”);
string input = Console.ReadLine();

int i = Int32.Parse(input);
if (i > 100)
{
no = i % 100;
if ((no > 10) && (no < 20))
no = 0;
else
no = i % 10;
}
else
no = i % 10;
switch (no)
{
case 0:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
Console.WriteLine(“Output:” + input + “th”);
break;
case 1:
Console.WriteLine(“Output:” + input + “st”);
break;
case 2:
Console.WriteLine(“Output:” + input + “nd”);
break;
case 3:
Console.WriteLine(“Output:” + input + “rd”);
break;
}
Console.WriteLine(“To exit:Y/N”);
con = Console.ReadLine();
} while (con!= “y”);
Console.Read();
}


Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: