Object
Write a program to read the number of hours worked by 5 employees. Now calculate overtime paid to them at the rate of Rs. 60 per hour, for every hour they worked above 45 hours.
Algorithm
- Declare integer variables wtm, otm and i.
- Repeat FOR i = 1 to 5 by 1
- Read wtm.
- IF(wtm > 45), then
- otm = (wtm – 45) * 60.
- Write otm.
- ELSE
- Write “no overtime paid”.
- [End of IF-ELSE structure.]
- [End of FOR loop.]
- Exit.
Flowchart

C++ Source Code
// program 40
#include <iostream>
using namespace std;
int main()
{
int wtm, otm, i;
for (i = 1; i <= 5; i++)
{
cout << "\n\nEnter the number of hours you have worked: ";
cin >> wtm;
if (wtm > 45)
{
otm = (wtm - 45) * 60;
cout << "You will be paid Rs. " << otm;
}
else
{
cout << "No overtime will be paid.";
}
}
return 0;
}
C Source Code
/*program 40*/
#include<stdio.h>
int main()
{
int wtm, otm, i;
for(i=1; i<=5; i++)
{
printf("\n\nEnter the number of hours you have worked: ");
scanf("%d", &wtm);
if(wtm>45)
{
otm = (wtm-45)*60;
printf("You will be paid Rs. %d", otm);
}
else
printf("No overtime will be paid.");
}
return 0;
}
Output
Enter the number of hours you have worked: 40
No overtime will be paid.
Enter the number of hours you have worked: 0
No overtime will be paid.
Enter the number of hours you have worked: 45
No overtime will be paid.
Enter the number of hours you have worked: 97
You will be paid Rs. 3120
Enter the number of hours you have worked: 107
You will be paid Rs. 3720
