24 lines
347 B
C
24 lines
347 B
C
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
int n;
|
|
int sum = 0;
|
|
|
|
numInput:
|
|
printf("Input integer: ");
|
|
scanf("%d", &n);
|
|
|
|
if (n < 1) {
|
|
puts("Error: Please type in non-zero positive integer.");
|
|
goto numInput;
|
|
}
|
|
|
|
for (int i = 1; i <= n; i++) {
|
|
sum += i;
|
|
}
|
|
|
|
printf("ANS: %d", sum);
|
|
|
|
return 0;
|
|
}
|