Hi guys, I've just started learning C and had a question. I am making a program that :
* Loops until user selects NO.
* In every loop it asks for an "int" value between (1-10), adds it to the previous value and displays it as "*".
I can get the variable to increment the new input value with the old one, like:
Code:
finalValue += oldValue
Problem--> However, when I try to display the finalValue as "*" its still working according to the value that was given to it the last time, not the total sum that has accumulated so far.
This is my actual code, I would really appreciate if someone could point out what is it that I am doing wrong
Code:
feedFinalScore = feedf(feedInput); /* getting its value from feedf function */
feedTotal += feedFinalScore;
printf("Feed level: ");
do {
printf("*");
j = j++; /* j set to 1 at the start */
} while ( j <= feedTotal);
printf("\n %d\n", feedTotal); /* echoes info to check if the total value is */
/* passed to the end of program or not */
When I try to run this, the last printf statement shows the accurate sum (the way it is supposed to, the total accumulated value of all loops) however the first printf statement (with the * ) shows only the last recent input(not the total value).
What I am wondering is, if its the same variable, how come the first printf statement isnt taking the value from that because one line after that, the variable still holds the right information.
I would appreciate any type of help.
Thanks.