Answer the question
In order to leave comments, you need to log in
How to organize instructions?
Hello ripple. I'm learning C# little by little and doing different tasks.
For example - From the interval [-X, X] (variable X - entered from the keyboard) find the number of positive numbers that are multiples of 3 and the number of negative even numbers.
I found positive ones, but how else can I find negative ones in the same place, is it possible to prescribe the condition in else if that i % 2 == 0 && i < 0, am I thinking right?
Here is the initial code -
Console.WriteLine("Input X number");
int X = int.Parse(Console.ReadLine());
for(int i = -X; i < X; i++ ){
if(i % 3 == 0 && i > 0){
Console.WriteLine("Result is = " + i);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question