Saturday 29 April 2023

Exercise 1-To demonstrate the use of data types, simple operators and expressions - 7

 7. 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”.
 

#include<stdio.h>
#include<conio.h>

void main()
{
 char m;

 clrscr();

 printf("\nFinding the first and last charcher of enter character on basis on ABC..");
 printf("\nEnter the characher:");
 scanf("%c",&m);
 printf("\nFirst character is:%c",m+1);
 printf("\nLast character is:%c",m-1);



 getch();
}

/*

Finding the first and last charcher of enter character on basis on ABC..       
Enter the characher:T                                                          
                                                                               
First character is:U                                                           
Last character is:S                                                            
 */

No comments:

Post a Comment

Questions

  Exercise 1 Set A . Apply all the three program development steps for the following examples.  1. Accept dimensions of a cylinder and p...