Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Assignment By Fasih Dawood

"Countings"

using System;

namespace ConsoleApp9

class Program

static void Main(string[] args)

string text = "This is the Cow. And a costly one";

int upcount = 0;

int lowcount = 1;

int spaces = 0;

int wrd = 1;

int vowels = 1;

int cons = 0;

int sen = 1;

for (int i = 0; i < text.Length - 1; i++)

if (text[i] > 64 && text[i] < 91)

upcount++;

else if (text[i] > 96 && text[i] < 123)

{
lowcount++;

else if (text[i].Equals(' '))

spaces++;

if (text[i] == ' ' || text[i] == '\n' || text[i] == '\t')

wrd++;

if (text[i] == 'a' || text[i] == 'e' || text[i] == 'i' || text[i] == 'o'


|| text[i] == 'u' || text[i] == 'A' || text[i] == 'E' || text[i] == 'I' || text[i] == 'O'
|| text[i] == 'U')

vowels++;

else if ((text[i] >= 'a' && text[i] <= 'z') || (text[i] >= 'A' && text[i]
<= 'Z'))

cons++;

if (text[i] == 46)

sen++;

}
}

Console.WriteLine("Upper Case Letters = {0}",upcount);

Console.WriteLine("Lower Case Letters = {0}" ,lowcount);

Console.WriteLine("Spaces = {0}",spaces);

Console.WriteLine("Words = {0}", wrd);

Console.WriteLine("Vowels = {0}", vowels);

Console.WriteLine("Consonants = {0}", cons);

Console.WriteLine("Sentences = {0}", sen);

Console.ReadKey();

You might also like