code in not working i have tried just every thing to print the difference i have used typecaste in mycode but i have also tried the char - char,string -string
here is my code;
https://ide.codingblocks.com/s/53651
Srings - Difference in Ascii Codes
mention problem link pls
Hey Ankush, this problem is pretty simple there is no need to use any conversion, as when you subtract a character from another character it results in an integer which is the difference of both chars ascii values. You can refer this code snippet
for(int i=1;i<k;i++){
char prev = a[i-1];
int diff = a[i]-a[i-1];
cout<<prev<<diff;
}
cout<<a[k-1];
1 Like
its printing some unkown chracter such as " ac b "
didi your code works perfect but why my code is not working at all
Hey, that’s because you are supposed to find the difference between every contiguous characters and you are not doing so, also your conversion is not correct.