Question


I need the soft code ( Outline with comments ) of the main program that reads in the employee data with the sorting, reading, and average functions as well as the class ( header file ). No hard code is necessary. Thank you!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>

struct emp
{
int emp_id ;
char emp_name[10] ;
int age ;
} e[10],temp;

void get_emp(int n)
{
int i;
for(i = 0 ; i < n ; i++)
{
printf("Enter the employee identification number : ") ;
scanf("%d", &e[i].emp_id) ;
printf("Enter the name of employee : ") ;
scanf("%s", e[i].emp_name) ;
printf("Enter age of employee : ") ;
scanf("%d", &e[i].age) ;
}
printf("\nEmp_ID\tName \t age \n") ;
for(i = 0 ; i < n ; i++)
{
printf("%d \t %s \t %d\n", e[i].emp_id,e[i].emp_name, e[i].age) ;
}
}

void sort_emp(int n)
{
int i,j;
for (i = 1; i < n; i++)
for (j = 0; j < n - i; j++)
{
if (e[j].emp_id>e[j + 1].emp_id)
{
temp = e[j];
e[j] = e[j + 1];
e[j + 1] = temp;
}
}
printf("\n*****After Sorting*****\nEmp_ID\tName \t age \n") ;
for(i = 0 ; i < n ; i++)
{
printf("%d \t %s \t %d\n", e[i].emp_id,e[i].emp_name, e[i].age) ;
}
}

void age_avg(int n)
{
int avg=0,tot=0,i;
for(i = 0 ; i < n ; i++)
tot+=e[i].age;
avg=tot/2;
printf("Average age of employee is: %d\n",avg) ;
}
void main()
{
int i, n,j ;
printf("Enter the number of employees : ") ;
scanf("%d", &n) ;
//read data of emp
get_emp(n);
//sorting according to id number
sort_emp(n);
//calculate average of employee age
age_avg(n);
  
}

Enter the number of employees : 2 Enter the employee identification number: 456 Enter the name of employee: abc Enter age ot

Add a comment
Know the answer?
Add Answer to:
I need the soft code ( Outline with comments ) of the main program that reads...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in BASIC/BEGINNER OBJECT ORIENTATED JAVA Please write code for the following program using comments explaining the...

    in BASIC/BEGINNER OBJECT ORIENTATED JAVA Please write code for the following program using comments explaining the code. (You can hand write this). Give a UML example illustrating AGGREGATION. Include classes, fields, methods, instance fields. USE ONE SUPER CLASS AND TWO SUB CLASSES. Include pcode for at least one method of each class. Explain the whole part relationship and if this a deep or shallow copy.

  • Need to fill the comments with code that works. Create The Starting Template for this program...

    Need to fill the comments with code that works. Create The Starting Template for this program is shown below. Fill in code where you see highlighted in these highlighted sections that do what the comments request. Don't modify maint) or the printCounts0 routine. When you run your program, you will need to eater in a string for the 'readString" method. Use a package named string methods for this program ructions in the methods readString), countOccurrences0.. ete. Write code the string:...

  • Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...

    Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly hours for all employees are stored in a text file where each line contains the employee name followed by the hours worked for each day of the week. The data is stored as follows (data is continuous in the file but represented in columns below): Kelly Brian Katie Michae Emily Jim John Jane Joe Doe Smith Hart Jones Hu Wright Young Green Hurley Write...

  • For assignment submission, use the format listed in the syllabus. Use comments in your code (5...

    For assignment submission, use the format listed in the syllabus. Use comments in your code (5 points will be deducted from each problem missing comments) Your solution must include header, implementation file, and client files. Consider a graphics system that has classes for various figures rectangles, squares, triangles, circles, and so on. For example, a rectangle might have data members for height, width, and center point, while a square and circle might have only a center point and an edge...

  • Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points...

    Create a c++ code and answer number 1 Homework Ch. 13 - Employee Class 30 points Design a class named Employee that has the following attributes: * Name ID Number- (Employee's] Identification Number " Department-the name of the department where the employee works " Position-the employee's job title The class should have the following constructors: A constructor that accepts values for all the member data as arguments A constructor that accepts the following values as arguments and assigns them to...

  • Linux & Unix Write a bash program to indent the code in a bash source file....

    Linux & Unix Write a bash program to indent the code in a bash source file. Conditions:     The source file will contain only printing characters, spaces, and newlines. It is not necessary to check for invalid input.     The source file will not contain comments (words beginning with #). Requirements:     Read from standard input, write to standard output.     Code inside while statements should be indented 2 spaces. Be sure your program includes all of the following:    ...

  • I NEED HELP with this. please create a UML diagram. I need a simple code to...

    I NEED HELP with this. please create a UML diagram. I need a simple code to solve the problem.   The ADT Bag is a group of items, much like what you might have with a bag of groceries. In a software development cycle, specification, design, implementation, test/debug, and documentation are typical activities. The details are provided in the rest of the document. ADT Bag Specification: (Note: You should not change the names of the operations in your program. This should...

  • (C++ Program) 1. Write a program to allow user enter an array of structures, with each...

    (C++ Program) 1. Write a program to allow user enter an array of structures, with each structure containing the firstname, lastname and the written test score of a driver. - Your program should use a DYNAMIC array to make sure user has enough storage to enter the data. - Once all the data being entered, you need to design a function to sort the data in descending order based on the test score. - Another function should be designed to...

  • Please post following code with criteria below... please leave as many comments as possible Exam Four:...

    Please post following code with criteria below... please leave as many comments as possible Exam Four: the election Outcome: Student will demonstrate all core competencies from this class: Program Design (design tools) Variables Decision Error Checking Looping Functions Arrays Program Specifications: Let’s pretend that we are tracking votes for the next presidential election. There will be two candidates: Ivanka Trump and Michele Obama. You can assume that there are fifty states casting votes. You will do not need to deal...

  • C++ code and also provide comments explaining everything Credit Card Debt The True Cost of Paying...

    C++ code and also provide comments explaining everything Credit Card Debt The True Cost of Paying Minimum Payment Write a C++ program to output the monthly payment schedule for a credit card debt, when each month nothing more is charged to the account but only the minimum payment is paid. The output stops when the balance is fully paid - remaining balance = 0. Input: Data input must be done in a separate function. Input the following: credit card balance,...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT