Tuesday, December 6, 2011

Write a C program to perform of Interchange charecter by ASCII code

#include <stdio.h>
#include <conio.h>
#include <string.h>
void main()
{
 char s;
 int a,n;
 clrscr();
 printf("This a program to convert upper case lower case and find ASCII value and IF You know ASCII Value , it find charecter and change case");
 printf("\n\n\n\tChange ASCII to charecter press 1 \n\tchange charecter to ASCII code press 2\n\tASCII Code to charecter Press 3\n\t know ASCII code to charecter Press 4::\n\t Enter your choice: ");
 scanf("%d",&n);
 switch(n)
 {
  case 1:
  {
   printf("\nEnter ASCII code: ");
   scanf("%d",&a);
   printf("Charecter is %c",a);
   if(a>=65&&a<=90)
   {
    printf("\nYou entered a upper case letter\nYour lower case letter is %c",(a+32));
   }
   if(a>=97&&a<=122)
   {
    printf("\nYou entered a lower case letter\nYour upper case letter is %c",(a-32));
   }
   break;
   case 2:
   {
    printf("\nEnter Charecter: ");
    scanf("%s",&s);
    a=s;
    printf("ASCII Code is %d",a);
    if(a>=65&&a<=90)
    {
     printf("You entered a upper case letter\nYour lower case letter is %c",(s+32));
    }
    if(a>=97&&a<=122)
    {
     printf("\nYou entered a lower case letter\nYour upper case letter is %c",(s-32));
    }
    break;
   }
   case 3:
   {
    printf("\nEnter Charecter: ");
    scanf("%s",&s);
    printf("ASCII Code is %d",s);
    break;
   }
   case 4:
   {
    printf("\nEnter ASCII: ");
    scanf("%d",&a);
    printf("Charecter is %c",a);
    break;
   }
   default:
   {
   printf("\n\tInvalid choice!!!");
   }
  }
 }
 getch();
}

No comments:

Post a Comment