I am able to calcualte depreciation for 1yr only but when i enter that programming in Loop but that fails and print the final total for no. of years enter by user.

Recommended Answers

All 2 Replies

ritesh_bhagat,
Welcome to the forum.
Post the pertaining snippet code that you have problems with. Don't forget to use proper code tags.

#include<stdio.h>
#include<conio.h>
main()
{
float fa,dp,dpa=0,na;
int y,i;
printf("Enter a Value of Assest");
scanf("%f",&fa);
printf("Enter the depreciation");
scanf("%f",&dp);
printf("Enter the No. of years to depreciate");
scanf("%d",&y);
for(i=0;i<=y;i++)
{
dpa = fa * dp / 100;
na = fa - dpa;
printf("%f is depreciation for the year and value of assest is %d",dpa,na);
}
getch();
}
commented: LEARN TO READ - Don't forget to use proper code tags. -2
commented: Equaliser +12
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.