C Code 38 _ To Find whether the given string has the characters arranged in alphabetical sequence order or not

C Code 38 _ To Find whether the given string has the characters arranged in alphabetical sequence order or not


Sample Input 1:

cdeg

Sample Output 1:

Characters are NOT in Sequence


Sample Input 2:

uvwxyz

Sample Output 2:

Characters are in sequence


Program:


#include<stdio.h>
int main()
{
int n,i,a,b,d=0;
char c[30];
printf("Enter a string of characters : ");
gets(c);
n=strlen(c);
for(i=0;i<n-1;i++)
{
a=c[i];
b=c[i+1];
if((a)!=(b-1))
{
d=1;
break;
}
}
if(d==0)
{
printf("\n\nThe Given Characters are in Sequence");
}
else
{
printf("\n\nThe Given characters are NOT in Sequence");
}
return 0;
}


Output:













Thank You ...


Popular Posts