Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,990 questions

51,935 answers

573 users

How to calculate depreciation per years in C

1 Answer

0 votes
#include <stdio.h>

int main(void) {
    double amount, deppercent, years;
          
    amount = 1000;
    deppercent = 40; // 40%
    years = 3;
          
    double amount_left = amount;
    double annual_depreciation = 0;
         
    printf("Initial amout = %.2f\n", amount_left);
          
    for(int i = 0; i < years; i++) {
        annual_depreciation = (deppercent * amount_left) / 100;
        amount_left = amount_left - annual_depreciation;
        printf("Year %d: Annual depreciation = %.2f Amount left = %.2f\n", i + 1, annual_depreciation, amount_left);
    }
  
    printf("Amount after depreciation = %.2f\n", amount_left);
}
  
  
  
  
  
/*
run:
   
Initial amout = 1000.00
Year 1: Annual depreciation = 400.00 Amount left = 600.00
Year 2: Annual depreciation = 240.00 Amount left = 360.00
Year 3: Annual depreciation = 144.00 Amount left = 216.00
Amount after depreciation = 216.00
   
*/

 



answered Aug 15, 2021 by avibootz

Related questions

1 answer 118 views
1 answer 168 views
1 answer 147 views
1 answer 173 views
1 answer 153 views
1 answer 335 views
1 answer 161 views
...