# count characters iterative
def count_chars(s)
count = Hash.new(0)
s.split("").each do |x|
count[x] += 1
end
count
end
# count characters functional
s.chars.map {|c| [c, s.chars.count(c)] }.to_h
std::string hello = "Hello";
int len = 1;
for(const char charac : hello)// Here the for loop take each character
// one by one and initialize it to charac.
// What happened in the for loop is
// for loop took the first character in hello
// and initialized it to charac(This was in the first loop)
// and so on until it processes all the characters
{
++len;
}// Note : in any string variable there is always a space at the last(as below)
std::cout << "Number of characters is " << numofchars - 1;