-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexo8.c
More file actions
30 lines (29 loc) · 673 Bytes
/
exo8.c
File metadata and controls
30 lines (29 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
int main(){
int sum, i, n;
double avg;
sum = 0;
while(n != 0){
printf("Enter a number: ");
scanf("%d", &n);
if (n == 0){
break;
}
if (n < 0){
printf("Please enter a positive number\n");
}
else{
sum = sum + n;
}
i++;
}
avg = sum / i;
printf("The sum of the numbers is: %d\n", sum);
printf("The average of the numbers is: %f\n", avg);
printf("\n");
printf("\n");
printf("\n");
printf("---------------------------------------------------\n");
printf("Made by: Ahmed Belmehnouf");
return 0;
}