TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
harish reddy
NA
162
33.4k
Alphabets counts
Apr 9 2018 12:35 AM
//Write a program that reads a string from the console and prints in alphabetical order all letters from the input string and how many times each one of them occurs in the string.
Pls help i amnot getting output
string text = "dadda";
char[] newarray = text.ToArray();
Array.Sort(newarray); int count = 1;
foreach (var item in newarray)
{
Console.WriteLine(item);
}
for (int i = 0; i < text.Length; i++)
{
for (int j = i + 1; j >= i; j++)
{
if (text[i] == text[j])
{
count++;
}
} Console.WriteLine("{0} appears {1} times", text[i], count);
}
My expected output is :
d appears 3 times
a appears 2 times.
Reply
Answers (
5
)
how to use gizMox Tools with C#
Create rounded button?