Tuesday, May 15, 2012

Test Programming with C Problem 7

/*Problem 7: Rahim's basic salary is input through the keyboard. His House rent allowance is 30% of basic salary and medical allowance is 5% of basic salary. He gets extra 1000 tk as technical allowance. Write a program to calculate his gross salary and print the result. */

#include<stdio.h>
#include<conio.h>

float calc_sal(float sal);

int main()
{
    float b_salary, total;
   
    printf("Please input Rahim's basic salary:\n");
    scanf("%f", &b_salary);
   
    total = calc_sal(b_salary);
   
    printf("Rahim's gross salary : %f\n", total);
   
    getch();
    return 0;
}
float calc_sal(float sal)
{
      float total;
      total = sal + (sal * 0.30) + (sal * 0.05) + 1000;
      return total;     
}

No comments:

Post a Comment

No Spamming Please.