Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C language. The code must be able to run on Visual Studio. Exercise 8.1 A word i

ID: 3714142 • Letter: C

Question

C language. The code must be able to run on Visual Studio.

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, befist, behint, beknow, bijoux, biopsy, cestuy, chintz, deflux, dehors, dehort, deinos, diluvy, dimpsy a. Describe an algorithm for checking whether a given word (String) is abecedarian, 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

#include<stdio.h>

#include<string.h>

void IsAbecedarian(char a[100])

{

int i,flag=1;

int size;

size=strlen(a);

for(i=0;i<size-2;i++)

{

if (a[i+1] < a[i])

{

flag = 0 ;

break;

}

}

if(flag == 0)

printf(" The String entered is not abecedarian");

else

printf(" The String entered is Abecedarian ");

}

int main()

{

char str[100];

printf("enter a string: ");

scanf("%s",str);

IsAbecedarian(str);

return 0;

}