i know my code is wrong but don’t know how to correct it
Tried much but showing wrong answer
the logic here is fairly simple. Just iterate from i = 0 to str.length() - 2 and take the difference and append it to the answer.
@saurabh_singhCmn
that is where i am struck
difference will be integer and how to append integer to the string ??
Use Integer.toString(yourInteger) function
int a = 10;
String ans = “”;
ans += “anuj”;
ans += Integer.toString(a);
System.out.println(ans);
prints anuj10
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.
bhai tumne toh yr doubt create kr diye
- yeh sab mere course m h kahi ??
- System.out.println(ans); bhai yeh function kese kaam krta h
Are you from the C++ course
yes, i have c++ launchpad
but till now i have not read these function in the course
Okay, I’m really sorry for the issue. I thought you were from the Java courses. Anyways, for C++ you can simply cout first the string, then put<< and then write the number.