0

Extra terrarian

The code just says no output. I have checked but i can't find any mistakes https://code.sololearn.com/c64T8TSiwdjr/?ref=app

26th Mar 2020, 6:58 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
21 Answers
0
use this instead : for(int i = y-1; i>=0; i--) because in an array 'arr', the index of the last item is arr.Lenght-1.
27th Mar 2020, 7:00 AM
John Robotane
John Robotane - avatar
+ 2
I made this code for you, it has a description of each step. You can find more info in Microsoft's documentation page. https://code.sololearn.com/cWu9Kk2Ejlx8/?ref=app
26th Mar 2020, 8:25 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
+ 1
I think you should change the condition in the loop, use i>=0 instead.
26th Mar 2020, 7:30 AM
John Robotane
John Robotane - avatar
+ 1
no, I tried. the for loop should look like that: for(int i = y-1; i>=0; i--)
26th Mar 2020, 8:25 AM
John Robotane
John Robotane - avatar
+ 1
Oh thanks
26th Mar 2020, 8:27 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
+ 1
To both
26th Mar 2020, 8:28 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
+ 1
namespace SoloLearn { class Program { static public string reverse(string s) { if (s.Length != 0) // if the string is NOT empty { char[] charArray = s.ToCharArray(); // creates CharArray from string s Array.Reverse(charArray); // uses native Array.Reverse method return new string(charArray); //returns string } else //if s is empty { return s; //returns empty string } } static void Main(string[] args) //main { string reverseme = "This should be reversed"; //created string Console.WriteLine(reverse(reverseme)); //using the method } } }
27th Mar 2020, 7:02 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
+ 1
Ok thanx
27th Mar 2020, 7:02 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
But it would write the word the same as before
26th Mar 2020, 8:19 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
Now it says unhandled exception please help
27th Mar 2020, 6:41 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
Well, again show me your code so I can see the exception.
27th Mar 2020, 6:46 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
0
I edited it did it not change
27th Mar 2020, 6:48 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
Just flip the greater than sign and you will see
27th Mar 2020, 6:49 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
What greater sign? Did you use the code that I wrote?
27th Mar 2020, 6:50 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
0
I couldn't really understand it
27th Mar 2020, 6:51 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
Can't it be done the way I am doing
27th Mar 2020, 6:51 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
Go to the top right corner. There are three points. Tap on "save" after you edit it.
27th Mar 2020, 6:53 AM
Fernando Pozzetti
Fernando Pozzetti - avatar
0
Try it now
27th Mar 2020, 6:55 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
The code in the question
27th Mar 2020, 6:55 AM
Nightcore Safe Heaven
Nightcore Safe Heaven - avatar
0
static void Main(string[] args) { string x = Console.ReadLine(); int y = x.Length ; for(int i = y ; i > 0 ; i--) { Console.WriteLine(x[i]); } Is that your code?
27th Mar 2020, 6:55 AM
Fernando Pozzetti
Fernando Pozzetti - avatar