How to solve Strings difference in ascii codes

I have done to just print
//Strings difference in ascii codes
#include
#include
#include
#include<string.h>
using namespace std;

int main(){

int j,d,i,n,p,k;
char a[100];
cin>>a;
n=strlen(a);
for(i=0;i<n-1;++i){
cout<<a[i];
d=a[i+1]-a[i];
cout<<d;
}
cout<<a[n-1];
}
my program does not add difference in the string
Please tell me correct approach to solve this problem

There are two ways of doing this:

  1. Use an empty string and keep appending characters in that and print that string at last.

  2. Instead of char array, use string and then use string.insert(pos,char) to insert at specific position.

Hope, this would help.
Give a like, if you are satisfied.