Compare commits
4 Commits
f4cbeaeee1
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f8373a9288 | ||
|
|
ac760d6f42 | ||
|
|
7cec159017 | ||
|
|
aa17c68aa5 |
11
sum.c
11
sum.c
@@ -11,11 +11,14 @@ int main() {
|
|||||||
int size = 1;
|
int size = 1;
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
int end_scan = 1;
|
||||||
int* arr = malloc(size * sizeof(int));
|
int* arr = malloc(size * sizeof(int));
|
||||||
|
|
||||||
while(TRUE) {
|
while(end_scan) {
|
||||||
printf("Enter a number: ");
|
printf("(Type EOF to end) Enter a number: ");
|
||||||
scanf("%d", &(arr[pos]));
|
if (scanf("%d", &(arr[pos])) == EOF) {
|
||||||
|
end_scan = 0;
|
||||||
|
}
|
||||||
if( arr[pos] == 0 ) {
|
if( arr[pos] == 0 ) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -30,7 +33,7 @@ int main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
free(arr);
|
free(arr);
|
||||||
printf("You sum is: %d\n", sum);
|
printf("Your sum is: %d\n", sum);
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user