‘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

Popular posts from this blog

Write a program to allocate memory dynamically for n integers. Accept the elements and calculate their sum and average

C program to accept names of n cities and search for city named “Pune”.