Write a C Program to accept a character from the keyboard and display its previous and next character in order. Ex. If character entered is ‘d’, display “The previous character is c”, “The next character is e”.

#include<stdio.h>
#include<conio.h>
void main()
{
   char letter; 
   //accept character
   printf("Enter the character: ");
   scanf("%c",&letter);
   printf("Previous character of %c is %c", letter, letter-1);
   printf("\nNext character of %c is %c",letter, letter+1);
   getch();
}

0 Comments