C# Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - General Questions (Q.No. 2)
2.
Which of the following is the correct output for the C#.NET program given below?
int i = 20 ;
for( ; ; )
{
Console.Write(i + " ");
if (i >= -10)
i -= 4;
else
break;
}Discussion:
20 comments Page 2 of 2.
Ashok said:
1 decade ago
What does this for (; ;) means?
Divya
This is use for infinity loop. it is use in server only.
Divya
This is use for infinity loop. it is use in server only.
Charu said:
1 decade ago
I think output should be 20 16 12 8 4 0 -4 -8
exclude -12,coz -12 is less than -10
exclude -12,coz -12 is less than -10
Harish said:
1 decade ago
(; ;) means that loop will run on the basis of conditional statement inside it.
Sunshine said:
9 years ago
@Latha, It is not 10, but -10 (minus 10). So the answer for sure is C.
AmuthaG said:
9 years ago
While Compilation it shows only from 20 to -12.
Siddhi said:
1 decade ago
Can we write break statement in else?
Sunil said:
1 decade ago
Can we write break in else part?
Sekhar reddy said:
1 decade ago
Briefly explain the code please.
Divya said:
1 decade ago
What does this for (; ;) means?
Mouli said:
1 decade ago
What does for(; ;) indicates?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers