C
C#14mo ago
נייסוס

✅ just need some help using if funcs nothing hard


int num1,num2,num3,num4;
Console.WriteLine("Enter a number: ");
num1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter a number: ");
num2 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter a number: ");
num3 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter a number: ");
num4 = int.Parse(Console.ReadLine());
if (num1 < 0 || num2 < 0 || num3 < 0 || num4 < 0);
{
Console.WriteLine("The numbers you wrote are negative!");
return;
}

int num1,num2,num3,num4;
Console.WriteLine("Enter a number: ");
num1 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter a number: ");
num2 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter a number: ");
num3 = int.Parse(Console.ReadLine());
Console.WriteLine("Enter a number: ");
num4 = int.Parse(Console.ReadLine());
if (num1 < 0 || num2 < 0 || num3 < 0 || num4 < 0);
{
Console.WriteLine("The numbers you wrote are negative!");
return;
}
7 Replies
נייסוס
נייסוסOP14mo ago
if (num1 < 0 num2 < 0 num3 < 0 || num4 < 0); in this line i want to specify that if any of these variables are negatives then the code will stop working but it doesnt work
Dawwa | Слава Украине
what do you mean doesn't work? doesn't evaluate it as true?
נייסוס
נייסוסOP14mo ago
when i enter only positive numbers in still stops the code
SinFluxx
SinFluxx14mo ago
you have a ; at the end of your if statement if (num1 < 0 || num2 < 0 || num3 < 0 || num4 < 0); should be: if (num1 < 0 || num2 < 0 || num3 < 0 || num4 < 0)
נייסוס
נייסוסOP14mo ago
thank you 🙏
SinFluxx
SinFluxx14mo ago
$close
MODiX
MODiX14mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server