please tell me what is the error in the code
#include
using namespace std;
int main()
{
int n;
cin>>n;
char ch[n];
int i=0;
for(int i=0;i<n;i++)
{
cin>>ch[i];
}
cout<<ch[0];
while(i<n-1)
{
int result=0;
result=ch[i]-ch[i+1];
cout<<result<<ch[i+1];
i++;
}
}
Output is showing truncated
Hey @tharun
According to the question, you don’t need to input the no of characters n, just input the string and calculate n using the length function of the string and then proceed.
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.