
A program to calculate the bonus
#include <stdio.h>
int calculateBonus(int yearsWorked);
int main()
{
int ThilebansBonus = calculateBonus(14); (sticks the returns right here)
int EmmasBonus = calculateBonus(3);
printf("Thileban gets $%d \n", ThilebansBonus);
printf("Emma gets $%d \n", EmmasBonus);
return 0;
}
int calculateBonus(int yearsWorked){
int bonus = yearsWorked * 250;
if(yearsWorked > 10){ (if worked more than 10 years)
bonus += 1000;
}
return bonus; (runs some equations and returns the integer)
}
whenever you have a function anything other then void you have to mention what are you returning.
Same Thing
#include <stdio.h>
int calculateBonus(int yearsWorked);
int main()
{
printf("Thileban gets $%d \n", calculateBonus(14));
printf("Emma gets $%d \n",calculateBonus(3));
return 0;
}
int calculateBonus(int yearsWorked){
int bonus = yearsWorked * 250;
if(yearsWorked > 10){
bonus += 1000;
}
return bonus;
}
Comments
Post a Comment