Answer:
C++
#include <iostream>
using namespace std;
//////////////////////////////////////////////////////////////////////////////
void firstLast(char theString[], int array_length, char* first, char* last) {
first = &theString[0];
last = &theString[0];
//////////////////////////////////////////
for (int i=1; i<array_length; i++) {
if ((int)*first > (int)theString[i]) {
first = &theString[i];
}
if ((int)*last < (int)theString[i]) {
last = &theString[i];
}
}
//////////////////////////////////////////
cout<<"first-> "<<*first<<endl;
cout<<"last-> "<<*last<<endl;
}
//////////////////////////////////////////////////////////////////////////////
int main() {
char theString[] = {'c', 'a', 't', 's', 'd', 'A'};
char* first, *last;
int array_length = (sizeof(theString)/sizeof(*theString));
//////////////////////////////////////////////////////////
firstLast(theString, array_length, first, last);
//////////////////////////////////////////////////////////
return 0;
}
Step-by-step explanation:
I have used ASCII code values to compare alphabets and figure out whether a char is before or after another char. ASCII code values of chars can be found, in C++, by casting them with (int).