+ 1
C#. What i did wrong?
I want to make a rectangle, my cod is below using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { int lenght = Console.ReadLine(); int wight = Console.ReadLine(); for (a = 0; a < lenght + 1;a++) { for (b = 0; a < wight + 1;b++) { Console.WriteLine (#); } } } } } Errors: cs1040, cs1026, cs1002
5 Answers
+ 1
ReadLine() reads text, the string form. Convert to destination type.
int length = int.Parse( Console.ReadLine() ) ;
Same for next..
In loop a, b are undeclared. Declare it.
for ( int a = 0;
Same for b.
Console.WriteLine("#") ; enclose text in quotes " " .
WriteLine() adds line break.
Write() don't adds line break.
See deferences.
Hope it helps..
+ 1
Big thanks! I haven't programming about 2 months, do i forgot everything.
0
Ugh. Something is wrong again. I fixed everything, and now code works, but it's just "########################
###############################################".
I inserted: 2 and 2
0
Роман Плуталов
for (a = 0; a < lenght; a++)
{
for (b = 0; b < wight; b++) //b < wight, not a < wight....
{
Console.Write("#");
}
Console.WriteLine(); // adds line break
}