I have this program to write that Generate 100 lowercase letters randomly and assign to an array of characters (Chars[ ] ).
Count the occurrence of each letter in the array and save them in counts[ ].
Write a main function to test the different count. What i don't know get is what to write in char * createArray()?
A skeleton of the code is given below.

#include <iostream>
#include "RandomCharacter.h"
using namespace std;
const int NUMBER_OF_LETTERS = 100;
char * createArray();
void displayArray(char []);
int * countLetters(char []);
void displayCounts(int []);
int main()
{
// Declare and create an array
char * chars = createArray();
// Display the array
cout << "The lowercase letters are: " << endl;
displayArray(chars);
// Count the occurrences of each letter
int * counts = countLetters(chars);
// Display counts
cout << endl;
cout << "The occurrences of each letter are: " << endl;
displayCounts(counts);
return 0;
}
// Create an array of characters
char * createArray()
{
}
// Display the array of characters
void displayArray(char chars[])
{
}
// Count the occurrences of each letter
int * countLetters(char chars[])
{
}
// Display counts
void displayCounts(int counts[])
{
}

You can find a simple random number generator in <cstdlib>. From there it's a simple matter of selecting N random values from a list of letters:

#include <cstdlib>
#include <iostream>
#include <string>

int main()
{
    std::string alphabet = "abcdefghijklmnopqrstuvwxyz";
    
    for (int i = 0; i < 10; i++)
        std::cout << alphabet[rand() % alphabet.size()];
        
    std::cout << '\n';
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.