I'm working on a program that accepts ten lowercase letters and then displays the one that would come first in alphabetical order. I'm using an array right now and I'm a little stuck on the logic for deciding the output. Here's what I have so far:
Code:#include <iostream> using namespace std; #define SIZE 10 char firstLetter(char[],char); int main() { char letters[SIZE],y; cout<<"\nThe first letter in alphabetical order is\n"<< firstLetter(letters,y)<<endl; } char firstLetter(char letters[], char y) { int i; y=letters[0]; for(i=0; i<SIZE; i++) { cout<<"Please enter a lowercase letter: "; cin>>letters[i]; if (letters[i]<letters[SIZE-i]) { y=letters[i]; } } return y; }