Skip to content

Instantly share code, notes, and snippets.

@pprathameshmore
Created February 21, 2019 13:52
Show Gist options
  • Save pprathameshmore/c510a06191425cb624ca8a42887b8481 to your computer and use it in GitHub Desktop.
Save pprathameshmore/c510a06191425cb624ca8a42887b8481 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <math.h>
#define rate 5
struct User {
char name[20];
int account_no;
float loanAmount;
float installments;
} user;
float calculateInterest(float amount, float installments) {
//Calculate EMI
float simpleInterest = amount * installments * rate / 100;
return simpleInterest;
}
void acceptUser() {
printf("Enter your details \n");
printf("Enter your name : \n");
gets(user.name);
printf("Enter your account number \n");
scanf("%f", &user.account_no);
printf("Enter loan amount \n");
scanf("%f", &user.loanAmount);
printf("Enter installments \n" );
scanf("%f", &user.installments);
}
void display(char name[20], float emi) {
printf("Your name is \n" );
puts(name);
printf("Your Interest is %f\n", emi);
}
int main() {
acceptUser();
float simpleInterest = calculateInterest(user.account_no, user.installments);
display(user.name, simpleInterest);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment