Friday, July 31, 2009

How to write this specific program in C#?

I'd like to write a C# program in console application.


int starts with value 0


Loops 1000 times and each time it loops, add 2 two to the value.


Can anyone help me out.

How to write this specific program in C#?
for(int i=0;i%26lt;=1000;i=i+2)


{


//Your code here


}





but above programe not run 1000 times


you want 1000 loops use this





for(int i=0;i%26lt;2000;i=i+2)


{


//Your code here


}
Reply:try this code:





int num = 0; //number to be incremented by 2





for (int i=0; i%26lt;1000; i++, num+=2) {





}


No comments:

Post a Comment