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();
}
}
}
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