Advertisement
kamandos

HomeWork

Jul 12th, 2022
780
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.25 KB | None | 0 0
  1. #include <stdio.h>
  2. int main() {
  3.     int n, i, sum = 0;
  4.  
  5.     do {
  6.         printf("Enter: ");
  7.         scanf("%d", &n);
  8.     } while (n <= 0);
  9.  
  10.     for (i = 1; i <= n; ++i) {
  11.         sum += i;
  12.     }
  13.  
  14.     printf("Sum = %d", sum);
  15.     return 0;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement