+ 1
Its a program for reversing an arr,but th code is acc C++ for 12th,after compiling there's no error but I won't get the output?
13 ответов
0
+ 2
You can change your code to this:
for(int k=19;k>=0;k--){
out[19-k]=in[k];
}
for (int l=0; l<20; l++)
cout << out[l];
You can't use same index "i" for every loop cause it keeps changing.
+ 1
Good luck, I am not that into C++, I usually code in Java, so my syntaxes might be different than yours.
0
But we need to store the word in 'out' from 'in' ...so we need same var...isn't it
0
Yes, I stored it, in out[19-k]=in[k]
If you want words, then char can't store words you need to use string.
0
Its a char array..
it can store a word I think...
I hv introduced third array temp n did it like swapping but didn't got the output
0
Okay, give me a sample, what you want to input, and what you expect the output to be.
0
Just rev the input:
Blue
eulB
0
Yes thats a string. Char can hold only one letter.
In sololearn playground you have to enter it like this:
B
l
u
e
Split it in line.
0
Ok..then I will try to use strcpy n getline functions
0
If its working.. then good.. I haven't checked yet.. though it seems correct.. and you didn't use getline or strcpy
0
I tried getline n strcpy bt it didn't ..
So I used simply 'cin' instead
0
Okay, good