one-dimensional array

Create a one-dimensional array to read 20 alphabetical letters (your program should be able to detect and print out an error message if a non-alphabetical letter is entered). As each letter is entered, print a message saying ‘duplicate letter’ if the letter is already in the array. Write a function that can sort the array after all 20 letters have been entered. Write another function that print out the most frequent letter and number of times it was entered. Prepare for the case where all 20 letters are different, or all are the same

someone please help me
Create a one-dimensional array to read 20 alphabetical letters
char array[20];

then
if not a problem will someone be able to write the programme for me, becuase im stuck
Chances are that nobody will do yuour homework for you.

You need to show what you've managed so far, ask specific questions about things that you've tried that don't work, be willing to read and research what people tell you.

Show us what you've got. If you have zero code, not even an empty program that does nothing, then you're not going to get very far.
No-one will write the program for you.
Start by assigning values to the array you've been given.
Take the assignment in steps and ask specific questions if you cannot work them out yourself.
#include<iostream>

using namespace std;
void sortArray(char letters[20]);
void mostFreq(int freq[26],char letters[20]);

int main()
{

char letters[20];

int temp,freq[26]={0};

int i=0,j,letter;

cout<<"Enter 20 alphabets \n";

for(i=0;i<20;i++){

cin>>letters[i];

if (isalpha(letter[i])==0);
//if((letters[i]<'a'||letters[i]>'z'))
{


cout<<letters[i]<<" is not an alphabet"<<"\n";

i--;



else
{

temp= ++freq[letters[i]-'a'];

if(temp>1)

cout<<letters[i]<<" is a duplicate letter"<<"\n";

}

}
not like i havent done anything , i ve done in so many different ways , but im getting some errors , and not getting the output that i need .

if (isalpha(letter[i])==0);
//if((letters[i]<'a'||letters[i]>'z'))
{


cout<<letters[i]<<" is not an alphabet"<<"\n";

i--;



else
{

temp= ++freq[letters[i]-'a'];

if(temp>1)

cout<<letters[i]<<" is a duplicate letter"<<"\n";

this thing is bad i guess
if (isalpha(letter[i])==0);
is wrong.

it should be
if (isalpha(letter[i])==0)

No ; at the end
Topic archived. No new replies allowed.