Why it is showing run time error

Hi @Namanjain123
Run time error is because you have not allocated size to char a before taking input. To use this you have to take a string then take it as input.

String s;
cin>>s;
n=a.size()

Use this then you wont be facing any run time error.