Is it possible to have this Kind of FOR LOOP. I ran this cide byt it is not giving me any result | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is it possible to have this Kind of FOR LOOP. I ran this cide byt it is not giving me any result

using System; namespace Project { class MyClass { public static void Main(string[] args) { for (int i = 5; i <= 1; i--) { Console.WriteLine(i); } } } }

9th Oct 2021, 9:01 AM
omitogun toni
omitogun toni - avatar
4 Answers
+ 5
There is a problem with your syntax for(int i=5; i >=1; i--) If i is greater than 1, then you have a True statement & your code will continue. But 5 is not smaller than 1, so you have a false condition, loop stops
9th Oct 2021, 9:31 AM
Rik Wittkopp
Rik Wittkopp - avatar
+ 2
Hello, it seems you made an error in your logic. You set i = 5. In the next step, you say 5 <= 1. Do you see the logical error?
9th Oct 2021, 9:27 AM
Jibraeel Abdelwahhab
Jibraeel Abdelwahhab - avatar
0
*code *but
9th Oct 2021, 9:01 AM
omitogun toni
omitogun toni - avatar
0
Thanks I've seen the error
20th Oct 2021, 1:29 PM
omitogun toni
omitogun toni - avatar