when I store the difference of two char in string and print it
the value that should be print is a numeric value but, it prints after converting it in char.
how should i store the value of the difference in the string ???
Int value to store in string
hello @goyalvivek
why u r storing?
simple print while iterating the string.
btw to convert char to int simply subtract β0β from that char
can u please show it in a c++ line
i am unable to understand
let the int variable to be stored is βdβ
the location to be stored is in string βchβ
pls share ur code with me, i will try to modify it
can u please show it in a c++ line
i am unable to understand
let the int variable to be stored is βdβ
the location to be stored is in string βchβ
is this what u want?
complte code->
plz check the code i have turned the collaborate mode on
#include #include using namespace std; int main() { string ch; getline(cin, ch); int s = ch.length(); int d; for(int i = 1; i < s; i+=2) { d = ch[i] - ch[i - 1]; for(int j = s; j >= i; jβ) { ch[j] = ch[j-1]; } ch[s] = β\0β; s++; ch[i] = d; } for(int i = 0; i < s; i++) { cout<<ch[i]; } return 0; }
cant see any code in colaboration mode.
pls save ur code here-> https://ide.codingblocks.com/
and share its url with me
I hope Iβve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.