In this tutorial learn how you can write a c program to enter two alphabets and display how many alphabets lie between them.

We are using <ctype.h> and <stdlib.h> header files for this tutorial. ctype.h is used to diffrerent library function that we are going to use like:

toupper();

and stdlib.h is used for the function “abs”.

C programming is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, etc.


write c program to find how many alphabets lie between two alphabets



Write a Program to Find How Many Alphabets Lie Between Two Alphabets

Here is the code to enter two alphabets and display how many alphabets lie between them in C programming.

#include <stdio.h> //WAP to enter two alphabets and display how many alphabets lie between them.
#include <ctype.h>
#include <stdlib.h>
int main()
{
char first_word, second_word;
int word_count;
printf("Enter two alphabets.n");
first_word = getchar();
getchar();
second_word = getchar();
word_count = abs(toupper(first_word) - toupper(second_word)) - 1;
printf("There are %d alphabets in between %c and %c.", word_count,first_word,second_word);

return 0;
}

Test Live At Jdoodle


Conclusion

This is how you can enter two alphabets and display how many alphabets lie between them in c programming. Comment below if you like our tutorial.