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.
- i = 1.
- Repeat WHILE i<=5
- Read wtm.
- IF(wtm > 45), then
- otm = (wtm – 45) * 60.
- Write otm.
- ELSE
- Write “no overtime paid”.
- [End of IF-ELSE structure.]
- i++.
- [End of WHILE loop.]
- Exit.
Flowchart

C++ Source Code
// program 54
#include<iostream>
using namespace std;
int main()
{
int wtm, otm, i = 1;
while (i <= 5)
{
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.";
}
i++;
}
return 0;
}
C Source Code
/*program 54*/
#include<stdio.h>
int main()
{
int wtm, otm, i;
i = 1;
while(i<=5)
{
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.");
i++;
}
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: 50
You will be paid Rs. 300
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
