Answer to Question #314872 in C for Kavya

Question #314872

Write a program to read two alphabetical characters and print all the characters in-between them including the given ones. Consider the 26 alphabets in cyclic order.

Note: use lower case letters for input and output.

For example:


Test Input Result

1 k o k l m n o

2 y a y z a


1
Expert's answer
2022-03-20T14:41:21-0400
#include <stdio.h>

int main() {
    char ch1, ch2, ch;

    scanf("%c %c", &ch1, &ch2);
    ch = ch1;
    while (ch != ch2) {
        printf("%c ", ch);
        ch++;
        if (ch > 'z') {
            ch = 'a';
        }
    }
    printf("%c\n", ch);

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS