fork download
  1. #include <stdio.h>
  2.  
  3. // 1 - 2 +3 -4 +5 -6 +7 -8 +9 -10 의 수식을 구하시오
  4. int main(void){
  5. int sum = 0;
  6. int n = 0;
  7. int i = 0;
  8.  
  9. while (i < 10)
  10. {
  11. n++;
  12. if(n%2 == 0){
  13. n = -n;
  14. } else{
  15. n = n;
  16. }
  17. sum += n;
  18. i++;
  19. };
  20. printf("Hello C\n");
  21. printf("sum : %d 입니다.", sum);
  22. };
Success #stdin #stdout 0s 5432KB
stdin
Standard input is empty
stdout
Hello C
sum : -5 입니다.