westron

finance (printf, scanf)

Apr 8th, 2018
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <Windows.h>
  4. using namespace std;
  5.  
  6. void main()
  7. {
  8.     float x, y, p, year = 0;
  9.     printf("input x p y = ");
  10.     scanf("%f %f %f", &x, &p, &y);
  11.     while (x < y)
  12.     {
  13.         year++;
  14.         x += x / 100 * p;
  15.         x = nearbyint(x * 100) / 100;
  16.     }
  17.     printf("the result is %.0f\n\n", year);
  18.     system("pause");
  19. }
Add Comment
Please, Sign In to add comment