Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --------------------------------------------------------------------
- LIÊN HỆ
- Email: toichacchanthaydoi@gmail.com
- Facebook: https://www.facebook.com/son.trinhtrong.14
- FanPage: https://www.facebook.com/laptrinhchocuocsong
- Google+: https://plus.google.com/108976316226450934290/posts
- Điện thoại: 01696003856
- Lưu ý: Code được viết trên phần mềm Visual Stdio 2015.
- --------------------------------------------------------------------
- #define _CRT_SECURE_NO_WARNINGS
- #include <stdio.h>
- #include <conio.h>
- int main() {
- float currentPopulation = 6000000;
- /* Case 1: Beginner no use for loop
- // After 1 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 1 years the population is: %f", currentPopulation);
- // After 2 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 2 years the population is: %f", currentPopulation);
- // After 3 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 3 years the population is: %f", currentPopulation);
- // After 4 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 4 years the population is: %f", currentPopulation);
- // After 5 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 5 years the population is: %f", currentPopulation);
- // After 6 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 6 years the population is: %f", currentPopulation);
- // After 7 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 7 years the population is: %f", currentPopulation);
- // After 8 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 8 years the population is: %f", currentPopulation);
- // After 9 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 9 years the population is: %f", currentPopulation);
- // After 10 years
- currentPopulation += (currentPopulation * 0.018);
- printf("\nAfter 10 years the population is: %f", currentPopulation);
- */
- // Case 2: Use for loop
- int i;
- for (i = 1; i <= 10; ++i) {
- currentPopulation += currentPopulation * 0.018;
- }
- printf("\nAfter 10 years the population is: %f", currentPopulation);
- // Note: portion only natural results
- _getch();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement