This c# program prints both upper and lower case alphabets using 2 different approaches.
using System;
namespace SamplePrograms
{
class Alphabets
{
public static void Main()
{
// Loop from a thru z (lower case alphabets)
for (char alphabet = 'a'; alphabet <= 'z'; alphabet++)
{
Console.Write(alphabet + " ");
}
//Another way to print lower case alphabets
//for (int i = 0; i < 26; i++)
//{
// Console.Write(Convert.ToChar(i + (int)'a') + " ");
//}
Console.WriteLine();
// Loop from A thru Z (upper case alphabets)
for (char alphabet = 'A'; alphabet <= 'Z'; alphabet++)
{
Console.Write(alphabet + " ");
}
//Another way to print uppercase case alphabets
//for (int i = 0; i < 26; i++)
//{
// Console.Write(Convert.ToChar(i + (int)'A') + " ");
//}
Console.ReadLine();
}
}
}
Very good
ReplyDeleteAwesome <3
ReplyDelete