Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

By printf By scanf Not cin>> not cout<< 3. Write a program that will calculate a

ID: 3591856 • Letter: B

Question


By printf By scanf
Not cin>> not cout<< 3. Write a program that will calculate and print the salary of a worker for a particular month. The salary of a worker depends on his basic salary plus the overtime. The formula to be used is: total salary = basic-salary + (hours-overtime * rate per hour) where basic salary is a fix salary received by an employee every month, hours_overtime is the number of extra hours the employee has worked for that particular month, and the rate per hour refers to the rate the employee is entitled to for his overtime.

Explanation / Answer

#include <stdio.h>

int main()
{
double salary, totalSalary, rate;
int hours;
printf("Enter the basic salary: ");
scanf("%lf", &salary);
printf("Enter the number of overtime hours: ");
scanf("%d", &hours);
printf("Enter the hour rate: ");
scanf("%lf", &rate);
totalSalary = salary + (hours * rate);
printf("Total Salary: %lf ", totalSalary);
return 0;
}

Output: