C
C#2y ago
Danyal

✅ After a number is entered the program ends

After the number is input the program ends and it doesn't output anything else.
Console.WriteLine("Enter a positive whole number");
int NumberIn = Int32.Parse(Console.ReadLine());

int NumberOut = 0;
int Count = 0;

while (NumberIn > 0)
{
Count++;
int PartValue = NumberIn % 2;
NumberIn = NumberIn / 2;

for (int i = 1; i < Count; i++)
{
PartValue = PartValue * 10;
}

NumberOut = NumberOut + PartValue;
}

Console.WriteLine("The result is: {0}", NumberOut);
Console.WriteLine("Enter a positive whole number");
int NumberIn = Int32.Parse(Console.ReadLine());

int NumberOut = 0;
int Count = 0;

while (NumberIn > 0)
{
Count++;
int PartValue = NumberIn % 2;
NumberIn = NumberIn / 2;

for (int i = 1; i < Count; i++)
{
PartValue = PartValue * 10;
}

NumberOut = NumberOut + PartValue;
}

Console.WriteLine("The result is: {0}", NumberOut);
6 Replies
Servator
Servator2y ago
Servator
Servator2y ago
It works fine for me
Danyal
DanyalOP2y ago
For some reason it doesn't work for me unless I add a ReadLine at the end.
Servator
Servator2y ago
It works It works so fast you can't even see output After code execution it closes
Danyal
DanyalOP2y ago
Ohh. Thanks for the help.
Servator
Servator2y ago
np type /close
Want results from more Discord servers?
Add your server