Character to ASCII in C

How do i convert character to ascii value and then perform arithmetic operations on the ascii values and get the character of the ascci value? in c programming !
help asap

Replies

  • Aadesh
    Aadesh
    get the character of the *new* ascii value
  • Neeraj Sharma
    Neeraj Sharma
    Its all about format specifiers. Normally for printing a character, you use %c but instead of %c, if you use %d for character, it gives you the ascii value. For adding, add both the characters and store the result in integer variable, so that the ascii values are added. Following program will give a clear idea about it.

    #include
    int main()
    {
      char ch1='a',ch2='b';
      int add;
      printf("Ascii value of %c: %d",ch1,ch1);
      printf("Ascii value of %c: %d",ch2,ch2);
      add=ch1+ch2;
      printf("Character for Ascii value %d: %c",add,add);
      return 0;
    }

You are reading an archived discussion.

Related Posts

I need to carry out excavation just 1m away from the footing of an existing Stilt + 3 storied building. The footing of of the building is isolated type and...
Demolition of old buildings isn't a new thing. Modern explosives allow for a controlled demolition of buildings. But I haven't seen a controlled demolition of a high-rise building or a...
what is the purpose of high pressure and low pressure turbine in rankine cycle with reheat......first we applied the steam on high pressure turbine and after that low pressure turbine...
what is the part of a vapour compression refrigeration system to which if u remove from the system then it will stop working?
Google Play Store more or less has confirmed that android jelly bean will be the name given to android version 4.1. We earlier thought Android 5 will be officially called...