0

Need help and example so I can understand

1) Write a pseudocode algorithm to read a set of positive integers (terminated by 0) and print their average as well as the largest of the set.

24th Jan 2021, 4:18 PM
Setsuko
Setsuko - avatar
4 odpowiedzi
+ 3
You don't need loops or the final 0 for this if you can use the max(), sum() and len() functions. e.g. using Python, lst = [1, 3, 4, 2] average = sum(lst) / len(lst) # 2.5 largest = max(lst) # 4
24th Jan 2021, 4:46 PM
David Ashton
David Ashton - avatar
0
You can easily find on google You need one array one variable for sum take one variable for iteration array[n] sum=0 For loop sum=sum+array[i] this will give u sum find the average divide it by total number and use logic for greater number
24th Jan 2021, 4:22 PM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
i hate loops but thank you
24th Jan 2021, 4:23 PM
Setsuko
Setsuko - avatar
0
Setsuko you can do many creativity with loops try pattern programs after that u will like to play with loops
24th Jan 2021, 4:26 PM
A S Raghuvanshi
A S Raghuvanshi - avatar