There are two technical errors in this program:
1. You have declared the string for three character. By default the last character should be '\0'. So, can only enter two characters. If you enter 3 or more characters, compiler may show unexpected result. Source: http://www.programiz.com/c-programming/c-strings
2. str[0]+str[2] gives you 99 when you entered 1+2. It is because ASCII value of 1 is 49 and ASCII value of 2 is 50. When, character is stored in variable(or string), ASCII value corresponding to that number is stored instead of that character.
The permitted length of the user input in the scanf statement needs to be set too.
1 2
char str[4];
scanf("\n%3s",str);
Here, str[4] has space to hold 3 characters plus the null terminator.
Therefore, the input must be limited to a maximum of three characters, using %3s.