@heyiamthemorgue@SyntaxError2505 Ternaries are for assigning values, not managing control flow. Putting multiple statements into them is a quick way to hit precedence errors and sequence point bugs.
if/else gives you clean, clear execution order.
@Dark_Goldenrod Typing "123 456" gives two numbers, since scanf reads 123 and then 456 on the next loop. "abc" prints "Invalid input" and ends the program.
You're right that scanf is fragile. I'll check out fgets and strtoll for safer input handling.
I wrote a C program that finds the average of any number of inputs. It uses dynamic memory allocation (calloc and realloc) so the amount of data isn't limited.
@AnthonyJClink -1 is the quit value. It ends the program and prints the average of the numbers entered before it. I chose it because averages usually involve zero or positive numbers.
If you need negative numbers, you can change the quit value to something else.