Order PDF of any content from our website with a little minor Fee to donate for hard work. Online MCQs are fully free but PDF books are paid. For details: contact whatsapp +923028700085 Important notes based PDF Books are available in very little price, starting from 500/-PKR; Order Now: contact whatsapp +923028700085

Past Papers CS201- Midterm Solved Questions on Employee Salary Program Q&A

Q#1: How is the information about employees’ gross salaries obtained in the program, and what is the role of the numEmps variable?
Answer: The program obtains employees’ gross salaries through a function that inputs the values. The numEmps variable, entered by the user, represents the total number of employees. It determines the size of the array used to store gross salaries, ensuring the correct number of salaries is input.


Q#2: Explain the process of calculating net salaries in the program. How are tax deductions applied based on different salary brackets?
Answer: Net salaries are calculated by a function that applies tax deductions according to salary brackets. For each gross salary, a corresponding percentage of tax is deducted depending on the bracket:

  • 0โ€“5000
  • 5001โ€“10000
  • 10001โ€“20000
  • 20001 and above
    The resulting net salary is computed after applying the appropriate deduction.

Q#3: What is the significance of the lucky array, and how is it used to identify unlucky employees in the program?
Answer: The lucky array is used to identify “unlucky” employees. A function marks employees as unlucky if their net salary is equal to or higher than others in a lower tax bracket. The lucky array stores this information and is later used to print the employee numbers of those identified as unlucky.


Q#4: Explain the concept of passing parameters by reference and by value in the context of the sal array and the numEmps variable.
Answer:

  • The sal array is passed by reference to functions like calcNetSal, so any changes inside these functions directly modify the original array.
  • The numEmps variable is passed by value to the input function, meaning changes made to it inside the function do not affect the original variable in main. This ensures global array updates while keeping numEmps unchanged outside the function.
Contents Copyrights Reserved By T4Tutorials