C
C#13mo ago
Kuzo

✅ [Fixed]Class function wont output anything

c#
namespace DecToBin
{
public class BinClass
{

int Dec;
public int[] array = new int[8];
public BinClass(int Decim)
{ Dec = Decim; }

public void BinGet()
{
for (int a = 0; a < 8; a++)
{
array[a] = Dec % 2;
Dec = Dec / 2;
}
}

public void BinWrite()
{
for(int a=7; a<=0; a--)
{
Console.Write(array[a]);
wspace(a);
}
}

public void wspace(int x)
{
if (x % 4 == 0)
{
Console.Write(" ");
}
}

}
}
c#
namespace DecToBin
{
public class BinClass
{

int Dec;
public int[] array = new int[8];
public BinClass(int Decim)
{ Dec = Decim; }

public void BinGet()
{
for (int a = 0; a < 8; a++)
{
array[a] = Dec % 2;
Dec = Dec / 2;
}
}

public void BinWrite()
{
for(int a=7; a<=0; a--)
{
Console.Write(array[a]);
wspace(a);
}
}

public void wspace(int x)
{
if (x % 4 == 0)
{
Console.Write(" ");
}
}

}
}
c#
using DecToBin;
using System.Dynamic;

namespace Bin
{

class Binary
{
static void text(string txt)
{
Console.WriteLine(txt + Environment.NewLine);
}
static void Main(string[] args)
{
int[] BinA=new int[8];
text("Input Decimal Number");
int dec=Convert.ToInt32(Console.ReadLine());
DecToBin.BinClass Bin = new BinClass(dec);
Bin.BinGet();
Bin.BinWrite();

}
}
}
c#
using DecToBin;
using System.Dynamic;

namespace Bin
{

class Binary
{
static void text(string txt)
{
Console.WriteLine(txt + Environment.NewLine);
}
static void Main(string[] args)
{
int[] BinA=new int[8];
text("Input Decimal Number");
int dec=Convert.ToInt32(Console.ReadLine());
DecToBin.BinClass Bin = new BinClass(dec);
Bin.BinGet();
Bin.BinWrite();

}
}
}
16 Replies
Stan
Stan13mo ago
your loop in binwrite is off. you start counting at 7 and say if less than or equal to 0 it should do an iteration, which is never true because we start at 7 which is greater than 0 so to clarify, in a for loop thrres 3 things 1. initializing your loop counter 2. the condition to that must be true to continue an iteration (maybe you think it's the condition to stop instead) 3. Changing the loop counter
DΣX
DΣX13mo ago
how does this eval bot work again?
Stan
Stan13mo ago
eval bot?
DΣX
DΣX13mo ago
modix when he evaluates code
Stan
Stan13mo ago
oh, no clue actually, been wondering what that thing does myself xD
Kuzo
KuzoOP13mo ago
what the difference between condition to stop and condition to start ?
MODiX
MODiX13mo ago
ͷɐϊνΣ
REPL Result: Success
for(int a=7; a<=0; a--)
{
Console.Write(a);
}
for(int a=7; a<=0; a--)
{
Console.Write(a);
}
Compile: 406.432ms | Execution: 45.455ms | React with ❌ to remove this embed.
MODiX
MODiX13mo ago
ͷɐϊνΣ
REPL Result: Success
for(int a=7; a>=0; a--)
{
Console.Write(a);
}
for(int a=7; a>=0; a--)
{
Console.Write(a);
}
Console Output
76543210
76543210
Compile: 372.377ms | Execution: 72.587ms | React with ❌ to remove this embed.
Kuzo
KuzoOP13mo ago
damn... man i cant belive i m this dumb thanks
DΣX
DΣX13mo ago
!e is the command
Kuzo
KuzoOP13mo ago
damn i feel like i dropped out my brain and got it back now thanks a lot
Stan
Stan13mo ago
ehh happens to the best of us
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX13mo ago
Use the /close command to mark a forum thread as answered
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Kuzo
KuzoOP13mo ago
/close\
Want results from more Discord servers?
Add your server