Still getting wrong o/p


check this code its printing extra comma

hi @kishoretaru to avoid the extra comma you can store all the numbers inside a vector and then print the answer accordingly. Dont forget you have to print the square brackets as well!

Can you pls make the required change in the code

@kishoretaru please try on your own first, I’ll make changes if required

Ive tried it im not getting that, getting extra comma


make changes in this code
with comments

@kishoretaru instead of doing cout<<a[i]
Make a vector v
And do v.push_back(a[i])

After that iterate through this vector till n-1th element and print v[i] and comma also
Print the last element separately outside the loop, and don’t print comma there

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.