This is suppose to be an infinite LOOP
first you initialize the value of c outside of the loop statement... then inside the loop statement you did not initialize it (no need to because c already has value), then no condition and no update value (in the if statement)... some of the codes inside this loop should not have been necessary if you did code it as how it is supposed to....
Condition never becomes false pero since you put a break point... it will break out of loop after c=10... but I think this is not the right way to do this
For this one you need not provide an initial value because you just pass what was the value of c that you initialize outside the for Loop command... again not the way to do it... depending on the situation it might be use....
Later ko na sagutin iba....
----------------- UPDATE ---------------------
Let me move one-step backward first...
Ang tanong po ni TS ay kung ano ang pagkakaiba at kung papaano ginagamit ang FOR, WHILE, DO WHILE statements sa Csharp....
That is why I explained the differences and how it is supposed to be use.... Hindi ko po sinasabi na if you do this it will not work or na ito lang ang gamit ng bawat statements na ito... now going back to your challenge:
This will run. No doubt about it. But the question is, is this the right way to write this code????
I think I need to point out that the reason many would want to use the FOR LOOP statement is because you can effectively eliminate 3 lines of code and convert it to just a 1 liner "statement"....
the above code could have been written:
Code:
for(c=1;c<=10; c++){Console.WriteLine(c); }
You 4 lines of code is reduced to just a 1 liner
So what I am saying is that knowing when to use FOR LOOP, WHILE LOOP, and DO WHILE LOOP.... will save you some time, bytes, and MEM in the long run. On the above mentioned code, you could have just use a while loop instead if that was really your intention....
Code:
int c=1;
while(c<=10){
Console.WriteLine(c);
c++;
}
And still this is 1 line less from your for loop code
I am not gonna honor this question with an answer... What is this???? Are you testing my ability to code???? I don't need to prove anything to you... I am just lending a hand to TS because I think his question is genuine and it warrants an answer...
I am not looking for a contest here.... If you are a good programmer then good for you. Share those talent to the world