1.Simple interest
BeginnerRead a principal amount (whole rupees), a yearly rate (a decimal) and a number of years, then print the simple interest and the total amount, each with two decimal places. Simple interest is principal × rate × years / 100.
Show hint
Read with scanf("%d %lf %d", ...). Remember that double needs %lf in scanf but %f in printf.
Show solution
#include <stdio.h>
int main(void) {
int principal, years;
double rate;
if (scanf("%d %lf %d", &principal, &rate, &years) != 3) return 1;
double interest = principal * rate * years / 100.0;
printf("Interest: %.2f\n", interest);
printf("Total: %.2f\n", principal + interest);
return 0;
}25000
7.5
3
Interest: 5625.00
Total: 30625.00