CrazyEngineers
  • Character to ASCII in C

    Aadesh

    Member

    Updated: Oct 25, 2024
    Views: 1.1K
    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
    0
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Aadesh

    MemberJun 21, 2012

    get the character of the *new* ascii value
    Are you sure? This action cannot be undone.
    Cancel
  • Neeraj Sharma

    MemberJun 21, 2012

    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<stdio.h>
    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;
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register