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:...

  • C/C++ Final Project PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the...

    C/C++ Final Project PROGRAM DUE MONDAY OF FINALS WEEK. Minimum requirements, the program must include the following features: Create a program that interacts with the user. Use at least 3 objects (instances of different classes) Use at least one example of inheritance Use at least one pointer Use at least one pass by reference Use at least one overloaded function Use separate files for class definition, class function definition, cpp file that has main Use at least 2 loops Use...

  • I need help with an assignment, it invovles techniques such as web scraping to retrieve data...

    I need help with an assignment, it invovles techniques such as web scraping to retrieve data from the Internet using both Python built-in functions as well as third-party libraries. You can use Python's default editor IDLE (Integrated Development and Learning Environment) or a Python editor of your choice to complete this assignment. I need to do the  following: Write a program to test if a given page is found or not on the server. Write a Python program to download and...

  • 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...

  • I want to know how to translate the design into a computer program write an interface...

    I want to know how to translate the design into a computer program write an interface class java and please put on the comments I would use the eclipse This lab is a stepping stone to project 01. The ADT Bag is a group of items, much like what you might have with a bag of groceries. The ADT Bag should have the following operations. You should use the same operation names that are shown below. • create an empty...

  • I need an OUTLINE ONLY (pseudocode/comments). DO NOT DO THE PROGRAMMING ASSIGNMENT. Part I: PA3 Outline...

    I need an OUTLINE ONLY (pseudocode/comments). DO NOT DO THE PROGRAMMING ASSIGNMENT. Part I: PA3 Outline (10 points). Create an outline in comments/psuedocode for the programming assignment below. Place your comments in the appropriate files: main.cpp, functions.h, dealer.cpp, dealer.h, dealer.cpp (as noted below). Place into a file folder named LastnamePA3, the zip the content and hand in a zip file to Canvas. Part II: PA3: Car Dealership (40 points) For Programming Assignment 3 you will be creating a program to...

  • Hi, I need help with this Java GUI program. The instruction and code can be found...

    Hi, I need help with this Java GUI program. The instruction and code can be found below thanks. This GUI is the start of a simple number entry GUI class. The program displays four Buttons and every time the user clicks on a button, the corresponding button label appears on the bottom of the GUI. As a hint, you might break up the design of the GUI into two parts: one part holds the buttons, the other holds the completed...

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