No, you read into num exactly once, even if -1 was not the first input.
Your requirements state:
Write a C program to read positive integers, until the value -1 is read and print the average of...
Type: Posts; User: laserlight
No, you read into num exactly once, even if -1 was not the first input.
Your requirements state:
Write a C program to read positive integers, until the value -1 is read and print the average of...
You shouldn't "fix" the value of num. Rather, you should be reading into num in the body of the loop, exiting the loop when -1 is read.
Your loop condition is wrong. Actually, the choice of a for loop is inappropriate here; use a while loop (or do while loop) instead.