have a problem, when int n=1 float a and b variable's are still the same when n=0. i write this program without function it work.
without functionCode:float people(float firstyear, float grow){ float total; grow = firstyear / 100 * 4.5; firstyear= grow + firstyear; total=firstyear; return total; } int main() { float a = 65, b = 0; int n; for(n = 0; n < 5; n++){ printf("%.2f\n", people(a ,b)); } return 0; }
Code:int main() { float firstyear=650000, grow=0; int n; for(n = 0; n < 5; n++){ grow = firstyear / 100 * 4.5; firstyear= grow + firstyear; printf("%.2f\n", firstyear); } return 0; }