C examples for Operator:Arithmetic Operator
Tom invests $100 at 10% . Every year, the investment earns an interest equal to 10% of the original investment.
Jack invests $100 at 5% interest compounded annually. That is, interest is 5% of the current balance, including previous addition of interest.
#include <stdio.h> #define RATE_SIMP 0.10 //from ww w.j a v a2 s. co m #define RATE_COMP 0.05 #define INIT_AMT 100.0 int main( void ) { double tom = INIT_AMT; double jack = INIT_AMT; int years = 0; while (jack <= tom) { tom += RATE_SIMP * INIT_AMT; jack += RATE_COMP * jack; ++years; } printf("Investment values after %d years:\n", years); printf("tom: $%.2f\n", tom); printf("jack: $%.2f\n", jack); return 0; }