Output gives garbage value

this is the question https://hack.codingblocks.com/contests/c/537/240, my output prints a-1b-1c99 fr input= abc
my code https://ide.geeksforgeeks.org/8LJa6DJWZa

Hey Simran, in this problem you are supposed to append (arr[i+1] - arr[i]) after each element of array. And just do not print anything after the last element of the array, you can achieve that by using an if check.