Ticker

6/recent/ticker-posts

Simple interest and Compound interest Program




1. Simple Interest - 


#include <stdio.h>

int main()
{ int p,r,t,s;
    printf("Enter the principal,rate and time ");
    scanf("%d %d %d",&p,&r,&t); //Input the values
    s=(p*r*t)/100; //performing the operation
    printf("The simple interest is %d",s); // printing the value 

    return 0;
}

Output -

Enter the principal,rate and time 100
10
1
The simple interest is 10

2. Compound Interest - 

#include <stdio.h>
#include <math.h>
void main()
{ float p,r,t,ci;
    printf("Enter the principal,rate and time ");
    scanf("%f %f %f",&p,&r,&t); //Input the values
    ci=p*pow((1+r/100),t); //performing the operation

    printf("The compound interest is %.2f",ci); // printing the value 
} 

Output -

Enter the principal,rate and time 100
10
1
The compound interest is 110.00

Post a Comment

0 Comments