0

Hi everybody , i don’t get fully how to do it

Create a program in C that receives integers from the user until a zero or negative number is entered and outputs the number of positive numbers obtained, the minimum, maximum, and average values ​​among the numbers entered. #include <stdio.h> int main() { int a,sum =0; int sum1=0; float mid=0; printf("Vvedit perche chuslo: "); scanf("%d",&a); sum +=1; while(a>0) { printf("Vvedit nastypne chuslo: "); scanf("%d",&a); { if(a>0){ sum +=1; sum1 +=a; mid = (sum1/sum); } } } printf("kilkist dodatnih chusel %d\n",sum); printf("ceredne chuslo %.2f",mid) }

29th Nov 2020, 10:46 PM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
2 ответов
0
Hi Олександр Крижанивский , It seems your code is too big to fit in the Description that it got truncated by character limits. To avoid truncation, you can save your code in SoloLearn, and share the saved code link instead. Besides, saved code is easier to check because there's syntax highlighting and line numbering support, so it would be easier to point a line number which needs adjustments or fixes. Follow this guide to sharing your code. Paste the saved code link inside Description, to replace the raw text format code ☝ https://www.sololearn.com/post/75089/?ref=app
29th Nov 2020, 11:42 PM
Ipang
0
To change: Use a do-while loop, change sum to counter (it's confusing) and sum1 to sum, divide sum by counter only after the loop. To add: Add min and max variables, check if current value (a) is smaller/greater then current min/max (if yes update them)
29th Nov 2020, 11:54 PM
Angelo
Angelo - avatar