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