visual c++ - Updating define value in C++ -
i'm learner of c++ , i'm making assignment , can't seem update value.
it's must use define balance:
#define balance 5000.00
in end of statement can't seem able update balance:
printf("deposit successful!\nyou have deposited following notes : \n"); printf("rm100 x %d = rm %.2f\n",nd100,td100); printf("rm 50 x %d = rm %.2f\n",nd50,td50); printf("rm 20 x %d = rm %.2f\n",nd20,td20); printf("rm 10 x %d = rm %.2f\n\n",nd10,td10); dtotal=td100+td50+td20+td10; printf(" total = rm %.2f\n\n",dtotal); newbalance=5000+dtotal; printf("your current balance rm %.2f\n\n",newbalance);
i want update newbalance
become balance can continue withdrawal. can show bit of withdrawal
printf("\nwithdrawal successful!\n"); printf("%d notes x rm 50 = rm%d.00\n",wnotes,wamount); printf("your current balance rm %.2f\n\n",newbalance);
please give me suggestions.
you need understand how works , preprocessor in c/c++ languages. preprocessor used before program first run. used during converting program (text) machine code. want outside of preprocessor/compiler duty - part of program itself.
so if want changed during program run typically need use variables like:
double balance = 5000;
suggested @jacdeh in comments.
Comments
Post a Comment