done
This commit is contained in:
23
programs/p413/main.c
Normal file
23
programs/p413/main.c
Normal file
@@ -0,0 +1,23 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user