In C. Exercise 8.1 A word is said to be “abecedarian” if the letters in the word
ID: 3711344 • Letter: I
Question
In C.
Exercise 8.1 A word is said to be “abecedarian” if the letters in the word appear in alphabetical order. For example, the following are all 6-letter English abecedarian words. abdest, acknow, acorsy, adempt, adipsy, agnosy, be?st, behint, beknow, bijoux, biopsy, cestuy, chintz, de?ux, dehors, dehort, deinos, diluvy, dimpsy a. Describeanalgorithmforcheckingwhetheragivenword(String)isabecedarian, assuming that the word contains only lower-case letters. Your algorithm can be iterative or recursive. b. Implement your algorithm in a function called IsAbecedarian().
Explanation / Answer
Check if every char is less than next char, if yes then it is abecedarian else not
Here is code
int IsAbecedarian(char word[])
{
int i = 0;
if (word[i] == '') return 1;
while(word[i+1] != '') {
if (word[i] > word[i+1]) {
return 0;
}
}
return 1;
}