fork download
  1. using System;
  2.  
  3. public class MyLab
  4. {
  5. public static void Main()
  6. {
  7. int n = 0; int i = 0; int s = 0;
  8.  
  9. Console.WriteLine("Please enter value for N\n");
  10. n = int.Parse(Console.ReadLine());
  11.  
  12. s = 0;
  13. for (i = 1; i <= n; i += 1)
  14. {
  15. if (i % 2 == 0)
  16. {
  17. s = s + i;
  18. Console.WriteLine("Current value i=" + i + " S=" + s);
  19. }
  20. }
  21.  
  22. Console.WriteLine("Final result suma is S=" + s);
  23. }
  24. }
Success #stdin #stdout 0.06s 30044KB
stdin
4
stdout
Please enter value for N

Current value i=2 S=2
Current value i=4 S=6
Final result suma is S=6