Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <stdlib.h>
  4.  
  5. int main(void)
  6. {
  7.  
  8. int n = 0,
  9. sum = 0,
  10. c = 0,
  11. i;
  12.  
  13. printf("Indtast n\n");
  14. scanf("%d", &n );
  15.  
  16. for (i = 0; i <= n; i++) {
  17. sum += i;
  18. }
  19.  
  20. printf("Summen er %d\n", sum );
  21.  
  22. c = (n + 1) * n / 2;
  23.  
  24. printf("Sumto er %d\n", c );
  25.  
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement