100% c prog simple and compound interest using 'if else'

// program to find simple or compound interest
#include <stdio.h>
void main()
{
    int   principle, no_of_years, choice, i;
    float interest_percent,simple_interest,compound_interest,total_return,tatkal,temp;
    printf("\n enter 1 for simple interest and 2 for compound interest:");
    scanf("%d",&choice);
    printf("\n Enter principle, no_of_years,interest_percent");
    scanf("%d%d%f",&principle,&no_of_years,&interest_percent);
   
    if(choice==1)
    {
               simple_interest=(principle*no_of_years*interest_percent)/100;
               printf("\n principle=%d \n no_of_years=%d \n interest_percent=%f",principle,no_of_years,interest_percent);
               printf("\n simple interest in Rs=%f",simple_interest);
               printf("\n total_return in Rs=%f", principle+simple_interest);
    }
    else
    {
               temp=1+interest_percent/100;
               tatkal=1;
               for(i=1;i<=no_of_years;i++)
               {
                   tatkal=tatkal*temp;
               }
               total_return=principle*tatkal;
               printf("\n total_return in Rs=%f",total_return);
               printf("\n compound interest in Rs=%f",total_return-principle);
    }
}

ఔట్పుట్ తెర  ఇలా కనపడె


 enter 1 for simple interest and 2 for compound interest:1

 Enter principle, no_of_years,interest_percent1000 2 10

 principle=1000
 no_of_years=2
 interest_percent=10.000000
 simple interest in Rs=200.000000
 total_return in Rs=1200.000000
   

కామెంట్‌లు

ఈ బ్లాగ్ నుండి ప్రసిద్ధ పోస్ట్‌లు

100% C prog to write content into a file and then read it back onto the console

Spic macay

శ్రీరస్తు.. రామలింగ 18-1-24 (సూరసాని వారి ఆహ్వానము)