Skip to content
Programming101
Programmingoneonone
  • Home
  • CS Subjects
    • Internet of Things (IoT)
    • Digital Communication
    • Human Values
  • Programming Tutorials
    • C Programming
    • Data structures and Algorithms
    • 100+ Java Programs
    • 100+ C Programs
  • HackerRank Solutions
    • HackerRank Algorithms Solutions
    • HackerRank C problems solutions
    • HackerRank C++ problems solutions
    • HackerRank Java problems solutions
    • HackerRank Python problems solutions
Programming101
Programmingoneonone

C++ program to calculate the salary of the servant

YASH PAL, 31 July 202422 August 2024

In this article, we are going to write a C++ program to calculate the salary of the servant. user will enter the hours of a servant and the rate per hour the servant gets. and program will display the total salary of the servant.

C++ program to calculate the salary of the servant

C++ program to calculate the salary of servent

#include<iostream>
#include<conio.h>


int main(void)
{

    int hours, rate, overtime, pay, opay, total;

    std::cout<<"Enter the hours of servant = ";
    std::cin>>hours;
    std::cout<<"Enter the rate per hour = ";
    std::cin>>rate;

    if(hours > 40)
    {
        overtime = hours-40;
        pay = 40*rate;
        opay = overtime*2*rate;
        total = pay+opay;
    }
    else
        total = hours*rate;

    std::cout<<"The total salary of the servant is = "<<total;

return 0;
}

Output

Enter the hours of servant = 5
Enter the rate per hour = 5
The total salary of the servant is = 25
C++ Programming Tutorials coding problems solutions

Post navigation

Previous post
Next post

Pages

  • About US
  • Contact US
  • Privacy Policy

Programing Practice

  • C Programs
  • java Programs

HackerRank Solutions

  • C
  • C++
  • Java
  • Python
  • Algorithm

Other

  • Leetcode Solutions
  • Interview Preparation

Programming Tutorials

  • DSA
  • C

CS Subjects

  • Digital Communication
  • Human Values
  • Internet Of Things
  • YouTube
  • LinkedIn
  • Facebook
  • Pinterest
  • Instagram
©2025 Programmingoneonone | WordPress Theme by SuperbThemes