6.Write a program to find Small Letters, Capital Letters separately.
using System;
public class Program
{
public static void Main()
{
string Mystring = "SimpleWordforExAmple";
char[] chars;
char ch;
int length = Mystring.Length;
int cnt;
int totalcntupper = 0,totalcountlower=0;
chars = Mystring.ToCharArray(0, length);
Console.WriteLine("Sample words with capital letters : {0} ", Mystring);
for (cnt = 0; cnt < length;cnt ++)
{
ch = chars[cnt];
if (char.IsUpper(ch))
{
Console.WriteLine("Capital letter : {0}", ch);
totalcntupper++;
}
else if(char.IsLower(ch))
{
Console.WriteLine("Lower letter : {0}", ch);
totalcountlower++;
}
}
Console.WriteLine("Count of capital letter(s) : {0}", totalcntupper);
Console.WriteLine("Count of lower letter(s) : {0}", totalcountlower);
Console.ReadLine();
}
}
Output :
Sample words with capital letters : SimpleWordforExAmple
Capital letter : S
Lower letter : i
Lower letter : m
Lower letter : p
Lower letter : l
Lower letter : e
Capital letter : W
Lower letter : o
Lower letter : r
Lower letter : d
Lower letter : f
Lower letter : o
Lower letter : r
Capital letter : E
Lower letter : x
Capital letter : A
Lower letter : m
Lower letter : p
Lower letter : l
Lower letter : e
Count of capital letter(s) : 4
Count of lower letter(s) : 16
Capital letter : S
Lower letter : i
Lower letter : m
Lower letter : p
Lower letter : l
Lower letter : e
Capital letter : W
Lower letter : o
Lower letter : r
Lower letter : d
Lower letter : f
Lower letter : o
Lower letter : r
Capital letter : E
Lower letter : x
Capital letter : A
Lower letter : m
Lower letter : p
Lower letter : l
Lower letter : e
Count of capital letter(s) : 4
Count of lower letter(s) : 16