100% c prog simple and compound interest using switch

// 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 principle, no_of_years,interest_percent");
    scanf("%d%d%f",&principle,&no_of_years,&interest_percent);
    printf("\n enter 1 for simple interest and 2 for compound interest:");
    scanf("%d",&choice);
    switch(choice)
    {
        case 1:
               simple_interest=principle*no_of_years*interest_percent/100;
               printf("\n simple interest in Rs=%f",simple_interest);
               printf("\n total_return in Rs=%f", principle+simple_interest);
               break;
        case 2:
               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 principle, no_of_years,interest_percent1000 2 10
enter 1 for simple interest and 2 for compound interest:1
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 (సూరసాని వారి ఆహ్వానము)