Want to elicit average of entered real value,until negative value is entered. My problem is
My calculation don't quit when negative value is entered
It keep asks printf sentence for 3 time. What did I do wrong?
#include <stdio.h> int main(void) { double total = 0.0; double input=0.0; int num = 0; for (; input >= 0.0;) { total += input; printf("real number(minus to quit):"); scanf_s("%1f", &input); num++; } printf("average:%f \n", total / (num - 1)); return 0; }