Give me an error saying that the remainder
variable was not assigned. There are several parts of the code that I do not understand and would like explanation.
Write a program that continually reads in integer values until a four digit number in the range 111 to 9999 is entered. Display the number vertically i.e. each digit on a separate line. Example:
Input: 1234
Output:
1
2
3 4
static void Main(string[] args)
{
int number, remainder;
string s = "";
//Reading a 4-digit number between 1111 and 9999
do
{
Console.WriteLine("Enter a number between 1111 and 9999: ");
number = int.Parse(Console.ReadLine());
} while (number < 1111 || number > 9999);/*Por que tenho que pôr esta condição*/
//Breaking number and formatting it vertically in a string
while (number > 0)
remainder = number % 10;
s = remainder + "\n" + s;
number = number / 10;
// I did not notice anything of the 4 lines above, what do they do?
//Displaying number vertically
Console.WriteLine(s); // porquê visualizar a variável s?
Console.ReadLine();