C program to calculate compound interest using functions write code

itstudentjunction

C program to calculate compound interest using functions Write code


calculate compound interest:


Compound interest arises when interest is added to the principal, so that from that moment on, the interest that has been added also earns interest. This addition of interest to the principal is called compounding.

For Rs. 5000 at interest rate 10% every year, Amount with compound interest at end of first year is 5500. Amount with compound interest at end of second year is 6050 (5000 + 500 + 500 + 50 [interest on interest]) and at end of third year Amount with compound interest is 5000 + 500 x 3 + 50 x 2 + 50 + 5 = Rs. 6655

note: compound interest generated for first period of time ( year as per above example) is always equal to simple interest for first period of time. From second period onwards compound interest varies as interest on interest adds up.




write a C program to find compound interest without functions


write a C program to calculate compound interest without functions / write a C program for calculating compound interest without functions

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float p,t,r;
float i,compound,a;
clrscr();
printf("...To calculate compound interest.....\t")
printf("enter principal:\t");
scanf("%d",&p);
printf("enter rate of interest:\t");
scanf("%d",&r);
printf("enter time in years:\t");
scanf("%d",&t);
if((p<1)||(t<1)||(r<1))
printf("invalid");
else
{
a=(float)p*(pow(1+r/100.0,t));
compound=a-p;
printf("the compound interest is rs.%.2f",compound);
}
getch();
}

OUTPUT:

...To calculate compound interest.....

enter principal: 100

enter rate of interest: 10

enter time in years: 1

The compound interest is rs. 10





Write a C program to calculate compound interest using functions


write a C program to find compound interest using functions / write a C program for calculating compound interest using functions

#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float p,t,r;
float i, compound ,a;
clrscr();
printf("...To calculate compound interest.....\t")
printf("enter principal:\t");
scanf("%d",&p);
printf("enter rate of interest:\t");
scanf("%d",&r);
printf("enter time in years:\t");
scanf("%d",&t);
compound = ci( p, t, r );
printf("the compound interest is rs.%.2f", compound);
}

ci( int principal, int rate, int time)
{

if((prinipal<1)||(time<1)||(rate<1))
printf("invalid");
else
{
i=(principal*time*rate)/100.0;
printf("The compound interest is rs.%.2f",i);
int amount=(float)principal*(pow(1+rate/100.0,time));
return(amount-prinipal);
}
}

OUTPUT1:

...To calculate compound interest.....

enter principal: 200

enter rate of interest: 10

enter time in years: 1

The compound interest is rs. 20


run2:

...To calculate compound interest.....

enter principal: 200

enter rate of interest: 10

enter time in years: 2

The compound interest is rs. 42


other related programs



write a program in c to find or calculate Simple interest


WAP to calculate Simple interest using macros in c programming

list of c programs



Most popular programs

write a program to find factorial using c
WAP to Calculate Simple Interest
Check for even / odd
perfect or not
sum of two matrices
display numbers pyramid
show amicable pairs
factors of a number using for loop, while
prime factors of integer using functions recursion
write a C program to convert string to uppercase using strUpr
generate prime numbers using for loop
print pascal's Triangle using arrays
check reverse string arrays
find string length strlen
concatinate strings - pointers
write a C program to calculate compound interest using functions & without functions
armstrong number or not
print prime numbers using while
solve towers of hanoi
Display Floyd’s Triangle
Write a program for reverse string using pointers
prime or not
Show revers number
calculate LCM
concatinate strings using arrays

write a program to find palindrome or not
WAP to print sum of Digits
display transpose matrix
show lower triangle
multipiy two matrices
write a program to calculate GCD
strong number or not
find substring or not
string length using arrays
string length using pointers
concatinate strings using arrays
convert string to lowercase using strlwr
WAP to find factors
count no.of digits
show inverse of matrix
show reverse string strrev
display upper triangle
concatinate strings using strCat
convert string to lowercase without strlwr
palindrome string or not
substring position in a string
compare two strings using arrays
compare strings strcmp
find roots of quadriaic expression
show fibonacci numbers
factorial using recurrsion
sum of factorial series
convert decimal to binary
Write a program to print armstrong numbers

decimal to octal
compare two strings using pointers
decimal to hexadecimal
sum of n numbers
average of n
largest of two
largest of n

strong numbers
perfect numbers using for loop

Custom Search


C Programs Data structures Programs in c Data structures Programs in c++ Unix commands Linux commands C++ programs Data structures Algorithms Java Programs UML Diagrams Assembly Language Programs DBMS j2ee programming