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

What is difference between string and string builder?

979


What are nested classes in c#?

955


What is routing in c#?

912


What is the example of predicate?

921


in the nunit test framework, which attribute must adorn a test class in order for it to be picked up by the nunit gui?

1160


What are the generation of Garbage Collection in C# .NET ?

957


What is c# in asp net?

931


What is gui in c#?

975


What is dictionary collection in c#?

921


How can I check the type of an object at runtime?

966


Explain use of abstract and sealed classes in c#?

858


Explain About namespaces

987


What is generic delegates in c#?

965


Why do we use generics in c#?

985


Define an assembly in .net?

963