-
2 Attachment(s)
Extra input !!!
Attachment 14898Attachment 14897
The program is taking an extra char and doesn't show the result before that .... There r no errors or warnings ... The program is for finding the sum n average of n integers... anyone can help ? .... N ya Turbo C++ is what i used because my college believes its better for learning n others are for working.
-
You should control the loop with the return value of scanf, e.g.,
Code:
while (inc <= loop && scanf("%d", &a) == 1)
This way, when scanf fails due to an error or end of input, the loop ends.
-
> N ya Turbo C++ is what i used because my college believes its better for learning n others are for working.
Ask your tutor how learning something that was made obsolete in 1990 prepares you for working in the outside world.
By the time you start work, it will no doubt be nearly 2020, and your knowledge will be 30 years out of date.
-
> Turbo C++ is what i used because my college believes its better for learning n others are for working.
Dafuq? A modern compiler and Notepad is a better option than Turbo C++. This is why onboarding a programmer fresh out of college takes so long; we have to undo all of the bad habits school introduced, reteach the language as it is now, and teach the tools that are actually used in the real world. :mad:
On a side note, your loop has an off-by-one error. When you enter 3, it loops four times due to starting at 0 and using <= as the condition.
-
Thank you @Prelude and @laserlight ..... n ya i agree with turbo c++ thing u all said ...