Write a Modular C Programming code to Compute the total salary of the employee.
“SIMBOSYS” is a reputed Company in Karnataka which has several departments and around 2,50,000 employees. The company is located in a prime location in the city and has good transportation facilities. There are around 4,000 well-qualified employees working in the company. An employee has different designations based on experience. The pay structure of the employee is as follows:
Apply problem-solving framework and UDF to compute the total salary of the employee.
Note: Increment has to be added to the salary.
Input Format
The character representing Designation and Salary
Constraints
Salary>=0
Character for Designation should be S/A/P.
Output Format
Incremented Salary.
Sample Input 0
S 150000
Sample Output 0
157500
Sample Input 1
D 100000
Sample Output 1
Invalid designation
Refer : C Programming HackerRank all solutions for Loops | Arrays | strings
CODE:
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int s; char c; scanf("%c",&c); scanf("%d",&s); if(s>=0) { if(c=='S') { if(s>=100000&&s<200000) { s=s+0.05*s; printf("%d",s); } else if(s<100000&&s>=70000) { s=s+0.03*s; printf("%d",s); } else if(s>=40000&&s<70000) { s=s+0.03*s; printf("%d",s); } } else if(c=='A') { if(s<160000&&s>=80000) { s=s+0.04*s; printf("%d",s); } else if(s<80000&&s>=50000) { s=s+0.05*s; printf("%d",s); } } else if(c=='P') { if(s<200000&&s>=100000) { s=s+0.09*s; printf("%d",s); } else if(s<100000&&s>=60000) { s=s+0.07*s; printf("%d",s); } else if(s<60000&&s>=40000) { s=s+0.05*s; printf("%d",s); } } else printf("Invalid designation"); } }
OUTPUT
Congratulations, you passed the sample test case. Click the Submit Code button to run your code against all the test cases. Input (stdin) S 150000 Your Output (stdout) 157500 Expected Output 157500
Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:
Top 100+ C Programming codes – KLE Technological University