Q. Accept a character from the keyboard and display its previous and next character in order.Ex. If the character entered is ‘d’, display “The previous character is c”, “The next character is e”.
Program
#include <stdio.h>
int main()
{
char ch;
printf("Enter character:\t");
scanf("%c", &ch);
printf("You entered: %c\n", ch);
printf("Previous character: %c\n", ch - 1);
printf("Next character: %c\n", ch + 1);
}
Output:
Enter character: f
You entered: f
Previous character: e
Next character: g
Program
#include <stdio.h>
int main()
{
char ch;
printf("Enter character:\t");
scanf("%c", &ch);
printf("You entered: %c\n", ch);
printf("Previous character: %c\n", ch - 1);
printf("Next character: %c\n", ch + 1);
}
Output:
Enter character: f
You entered: f
Previous character: e
Next character: g
3 Comments
show algorithm & flowchart of this C program
ReplyDeleteWrite a c program to read character from keyboard and display the entered character
ReplyDeleteAccept 5character display them
ReplyDelete