‘C’ program with menu to perform operations on a character.
C File =>
/*Write a ‘C’ program with menu to perform the following operations on a
character.
1. Check uppercase or lowercase
2. Display its ASCII value
3. Display its next and previous character
4. Exit */
#include<stdio.h>
#include<stdlib.h>
#include<ctype.h>
int main()
{
int ch;
char c;
printf("\n Enter any character : ");
scanf("%c",&c);
printf("\n Menu : \n1. Check uppercase or lowercase");
printf("\n 2. Display its ASCII value");
printf("\n 3. Display its next and previous character\n 4. Exit");
printf("\n Enter your choice (1-4)");
scanf("%d",&ch);
switch(ch)
{
case 1: if(isupper(c))
printf("Uppercase character");
else if(islower(c))
printf("Lowercase character");
else
printf("Neither lowercase nor uppercase");
break;
case 2:printf("\n ASCII value of characher %c is %d",c,c);
break;
case 3:printf("\n Previous character of %c is %c",c,c-1);
printf("\n Next character %c is %c",c,c+1);
break;
case 4: exit(0);
break;
default : printf("\n Invalid input...");
}
return 0;
}
Comments
Post a Comment
Please do not enter any spam link in message.