Tuesday 7 August 2012

Loop control structure013


Write a program to calculate overtime pay of ten empoloyes. Overtime is paid at the rate of Rs. 12.00 per hour for every hour worked above 40 hours. Assume that employees do not work for fractional part of an hour.

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

void main ( )
{
        float       otpay;
        int          hour, i = 1;
        clrscr ( );
              
        while ( i <=10 )              /* Loop for ten employees */
        {                   
                printf ("\n\n\t Enter number of hours worked ......:"); scanf ("%d",&hour);
                if ( hour >= 40 )
                {                            
                             otpay = (hour - 40 ) * 12;
                             printf ("\n\t Number of hours worked = %d \n\t Overtime pay = %f",hour, otpay);
                }                          
                else                     
                {                             
                             otpay = 0;
                             printf ("\n\t Number of hours worked (%d) is less than 40 hours \n\t Hence no 
                                                no overtime pay", hour);
                }
                i ++;
        }
        getch ( );
}

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...