Skip to content

Instantly share code, notes, and snippets.

@sachinsaxena25
Last active July 17, 2019 17:33
Show Gist options
  • Save sachinsaxena25/c5b9fb11eb8dea1a0be2534b2f100cea to your computer and use it in GitHub Desktop.
Save sachinsaxena25/c5b9fb11eb8dea1a0be2534b2f100cea to your computer and use it in GitHub Desktop.
#include<stdio.h>
int main(void){
float principle = 0.0f;
float time = 0.0f;
float rate = 0.0f;
float si = 0.0f;
printf("please enter the principle amount in :\n");
scanf("%f", &principle);
printf("please enter the time duration in years ex = 4 / 5.5 etc:\n");
scanf("%f", &time);
printf("please enter the rate of interest in %%:\n");
scanf("%f", %rate);
si = (principle * rate * time) / 100.0f;
printf("The Simple Interest Amount Calculated is = %.2f /-\n", si);
return 0;
}
@dbc2201
Copy link

dbc2201 commented Jul 17, 2019

Notes -

  1. The name of the file should not have any spaces like simple intereset.c, the name could be either of the following -
  • simple_interest.c - this is called "Snake Case"
  • simpleInterest.c - this is called "Camel Case"
  • SimpleInterest.c - this is called "Pascal Case"
  1. I have re-written the program for you, read it and note the differences -
#include<stdio.h>

int main(void) {
	float principle = 0.0f;
	float time = 0.0f;
	float rate = 0.0f;
	float si = 0.0f;
	printf("Please enter the principle amount in ₹:\n");
	scanf("%f", &principle);
	printf("Please enter the time duration in years ex - 4 | 5.2 etc:\n");
	scanf("%f", &time);
	printf("Please enter the rate of interest in %%:\n");
	scanf("%f", &rate);
	si = (principle * rate * time) / 100.0f;
	printf("The Simple Interest amount calculated is ₹ %.2f /-\n", si);
	return 0;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment