fork download
  1. // This is my first C language program
  2. #include <stdio.h>
  3.  
  4. int main(void) {
  5. int n = 0;
  6. int i = 0;
  7. int s = 0;
  8.  
  9. printf("Please enter value for N\n");
  10. scanf("%d", &n);
  11.  
  12. s = 0;
  13. for (i = 1; i <= n; i = i + 1) {
  14. if (i % 2 == 0) {
  15. s = s + i;
  16. printf("Current value i=%d S=%d\n", i, s);
  17. }
  18. }
  19.  
  20. printf("Final result suma is S=%d", s);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5292KB
stdin
1
2
10
42
11
stdout
Please enter value for N
Final result suma is S=0