Replies
Welcome, guest
Join CrazyEngineers to reply, ask questions, and participate in conversations.
CrazyEngineers powered by Jatra Community Platform
-
@aadesh-FqoMCL • Jun 21, 2012
get the character of the *new* ascii value
-
@neeraj-iAaNcG • Jun 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; }