The struct should include the following fields: name, which should point to a string elsewhere ssn, which should hold the 9 digits of a Social Security Number in an array in the struct yearBorn as int salary as int

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

in C code 

not c++

1. Define a struct for employees
The struct should include the following fields:
name, which should point to a string elsewhere
ssn, which should hold the 9 digits of a Social Security Number in an array in the struct
yearBorn as int
salary as int
Check that this code compiles, but it cannot run yet.
2. Define a global variable
The variable should hold a single employee and initialize the values with a { } initialization.
3. Display function
Write a display function that takes a pointer to an employee struct and prints the info as follows:
On the first line, print the name, the ssn and the year born.
The ssn should be formatted as the standard xxx-xx-XXxx
On the second line, print the salary with a leading $ and a , after the thousands place, such as $25,000. You don't have to worry about 7 digit salaries.
Write main so that it will call display, passing the address of the global employee record.
To help with this, you will need to use the special printf modifiers we covered in class.
Remember: You can control how many characters you print from a string with a number between the % and the s. For example, %3.3s will print exactly 3 characters
from the string, where the first 3 is the minimum number of characters to print and the second 3 is the maximum number of characters to print.
You can use a number like that with %d to force printing a certain width of digits. If you use a leading 0, if will 0 fill instead of blank filI. So %03d will print the number
4 as 004.
Transcribed Image Text:1. Define a struct for employees The struct should include the following fields: name, which should point to a string elsewhere ssn, which should hold the 9 digits of a Social Security Number in an array in the struct yearBorn as int salary as int Check that this code compiles, but it cannot run yet. 2. Define a global variable The variable should hold a single employee and initialize the values with a { } initialization. 3. Display function Write a display function that takes a pointer to an employee struct and prints the info as follows: On the first line, print the name, the ssn and the year born. The ssn should be formatted as the standard xxx-xx-XXxx On the second line, print the salary with a leading $ and a , after the thousands place, such as $25,000. You don't have to worry about 7 digit salaries. Write main so that it will call display, passing the address of the global employee record. To help with this, you will need to use the special printf modifiers we covered in class. Remember: You can control how many characters you print from a string with a number between the % and the s. For example, %3.3s will print exactly 3 characters from the string, where the first 3 is the minimum number of characters to print and the second 3 is the maximum number of characters to print. You can use a number like that with %d to force printing a certain width of digits. If you use a leading 0, if will 0 fill instead of blank filI. So %03d will print the number 4 as 004.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY