Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

f i give input like 1,1,4,5,6,1,2,5,4,1,2, then output
should be like : 1-4, 2-2, 4-2, 5-1, 6-1 which means 1
occurs 4 times, 2 occurs 2 times like so.

Answer Posted / shadab

using System;
class abc
{
public static void Main()
{
Console.WriteLine("Enter your number with
comma Like this 1,1,4,5,6,1,2,5,4,1,2 ");
string str=Console.ReadLine();
char []a=str.ToCharArray();

int
ctr1=0,ctr2=0,ctr3=0,ctr4=0,ctr5=0,ctr6=0,ctr7=0,ctr8=0,ctr9
=0,ctr0=0;
for(int i=0;i<a.Length;i=i+2)
{
if(Convert.ToInt32(a[i].ToString())
==1)
{
ctr1++;
}
if(Convert.ToInt32(a[i].ToString())
==2)
{
ctr2++;
}
if(Convert.ToInt32(a[i].ToString())
==3)
{
ctr3++;
}
if(Convert.ToInt32(a[i].ToString())
==4)
{
ctr4++;
}

if(Convert.ToInt32(a[i].ToString())
==5)
{
ctr5++;
}
if(Convert.ToInt32(a[i].ToString())
==6)
{
ctr6++;
}
if(Convert.ToInt32(a[i].ToString())
==7)
{
ctr7++;
}
if(Convert.ToInt32(a[i].ToString())
==8)
{
ctr8++;
}
if(Convert.ToInt32(a[i].ToString())
==9)
{
ctr9++;
}
if(Convert.ToInt32(a[i].ToString())
==0)
{
ctr0++;
}
}
Console.WriteLine("1 Occurs "+ctr1);
Console.WriteLine("2 Occurs "+ctr2);
Console.WriteLine("3 Occurs "+ctr3);
Console.WriteLine("4 Occurs "+ctr4);
Console.WriteLine("5 Occurs "+ctr5);
Console.WriteLine("6 Occurs "+ctr6);
Console.WriteLine("7 Occurs "+ctr7);
Console.WriteLine("8 Occurs "+ctr8);
Console.WriteLine("9 Occurs "+ctr9);
Console.WriteLine("0 Occurs "+ctr0);
}
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do canadians say zed?

994


When To use HashTable In C#

995


What is the difference between method overriding and method overloading?

917


What is new method in c#?

914


What is difference between ienumerable and ienumerator in c#?

917


Name some properties of thread class.

981


What are primitive types in c#?

965


What is wpf application in c#?

834


How many types of constructor are there in c#?

892


Is null in c#?

851


Explain nullable types in c#?

953


State the top.NET class that everything is derived from?

925


What does || mean in programming?

956


Are all methods virtual in c#?

932


Which attribute adorn a test class to be picked up by the NUnit GUI in the NUnit test framework?

975