Skip to content

Instantly share code, notes, and snippets.

@sachinsaxena25
Last active July 18, 2019 18:29
Show Gist options
  • Save sachinsaxena25/e968715e8ce2b90b1ccec24e96848b21 to your computer and use it in GitHub Desktop.
Save sachinsaxena25/e968715e8ce2b90b1ccec24e96848b21 to your computer and use it in GitHub Desktop.
#include<stdio.h>
int main(void){
int current_year = 0;
int year_of_joining = 0;
float year_of_services = 0.0f;
float bonus = 0.0f;
printf("please enter current year:");
scanf("%d", &current_year);
printf("please enter year of joining:");
scanf("%d", &year_of_joining);
year_of_services = current_year = year_of_joining;
if(year_of_services > 3)
{
bonus = 2500.0f;
printf("Calculated Bonus Rs: %.2f\n", bonus);
}
return 0;
}
@dbc2201
Copy link

dbc2201 commented Jul 18, 2019

  1. Every variable should not be float, think what should type of value you want to store.
  2. current_year and year_of_joining variables can be int simply.
  3. Line 11 should be year_of_services = current_year - year_of_joining;

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