Saturday 27 April 2013

lab @ home 10

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace ConsoleApplication4



{
class duplicate



{
static void Main(string[] args)



{
char[] ch = new char[5] { 'a', 'b', 'a', 'c', 'd' };

int i, count = 0;

Console.WriteLine("enter a character:");

char input = Convert.ToChar(Console.ReadLine());

for (i = 0; i < 5; i++)



{
if (ch[i] == input)



{

count++;

}

}


Console.WriteLine("{0} appears {1} times in the character array", input, count);

Console.ReadLine();





}

}

}

No comments:

Post a Comment