Friday 28 March 2014

7

C Program 3: To calculate the gross salary when the basic salary is entered through keyboard

  • Friday 28 March 2014
  • IndianBooktuber
  • Share
  • Aim: Ramesh's basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.
    Theory: We need to take input from user and then apply the simple formula to calculate the gross salary i.e. gross salary= basic salary+ dearness allowance+ house rent allowance.
    Following would be the program code:

    //to calculate the gross salary
    #include<stdio.h>
    #include<conio.h>
    int main()
    {
        int bs, gs, da, hr;
        printf("Enter the basic salary:");
        scanf("%d", &bs);
        da=40*bs/100; //given that dearance allowance is 40% of basic salaray
        hr=20*bs/100; //given that house rent is 20% of basic salaray
        gs= bs + da + hr; //formula to calculate gross salary
        printf("The gross salary is: %d", gs);
        getch();
        return 0;

    }

    First we asked the user to enter the basic salary and then take the input using the scanf("%d", &bs); statement. Now, we calculate the dearness allowance using this statement da=40*bs/100; Similary we will calculate the house rent allowance according to the values mentioned in the question and then we would use our main formula to calculate the gross salary  i.e. gs= bs + da + hr; 
    Outpur: 



    7 Responses to “C Program 3: To calculate the gross salary when the basic salary is entered through keyboard”

    Unknown said...
    23 September 2017 at 19:13

    Nice thankx


    Unknown said...
    3 August 2018 at 07:00

    Superb


    Unknown said...
    7 December 2018 at 05:00

    Thank you very much


    Unknown said...
    10 February 2019 at 21:19

    I need algorithm and flowchart
    Will i get it?


    Unknown said...
    10 February 2019 at 21:19

    ????


    Unknown said...
    19 April 2019 at 20:55

    Thanks


    Unknown said...
    5 September 2019 at 23:15

    Thank u


    Post a Comment

    Subscribe