C structs and enums

Assignment Help Computer Network Security
Reference no: EM131036844

Getting started

Change into the cse220 directory. Create a new directory called lab14.

Change into the new directory. Implement the program below in your lab14 directory.

C Structs and Enums

Struct variables

Create a header file capacitor.h.

Protect your header using #ifndef directive.

Define a struct with tag Capacitor that holds the following information about a capacitor: Model number (e.g. 11-123U), capacitance (e.g. 1000 uf), voltage (e.g. 2.5 V), cost ($6.50)

Create your main program file capacitorsInfo.c that uses the header file you just declared. Declare two variables of type struct Capacitor and populate them with the following values: First variable: model is 11-123U, capacitance is 100, voltage is 25 and cost is $6.00

Second variable: model is 65T91a, capacitance is 22000, voltage is 20 and cost is $25.00

Print the the model number of the first capacitor and the voltage of the second.

Create a makefile to build your program. Make sure it compiles and runs without errors. Remove your print statements.

Struct Array

Add a third Capacitor variable and initialize it from values entered by the user. Use fgets when reading the model number to make sure you don't exceed the size of your model number array.

Print to the standard output the members of the third capacitor and to make sure the capacitor is populated correctly.

Declare an array of Capacitors of size 4 and copy the three capacitors you created to the array. Populate the fourth element of the array from user input.

Manipulation with Functions

Add to capacitor.h the prototype of function displayCapacitorInfo that takes a capacitor as input parameter and prints its details in the following format:

Capacitor 11-123U:

*  Capacitance 100 uF

*  Voltage: 25 V

* Cost: $25.00

Add the function definition in a corresponding C file capacitor.c. Call your function in the main file on all members of the array.

Using typedef

Change the struct definition from using tag name to using typedef. Modify your program to work properly with the new definition.

Add (to capacitor.h/capacitor.c) a function largestCapacitance that takes as input an array of Capacitors and returns a pointer to the Capacitor with the largest capacitance.

Call largestCapacitance on your array and add statements to print the cost of the capacitor returned by the function.

Using Enum

In the header file capacitor.h, define an enumeration CapType with the following values: Ceramic, Aluminum, Film, Supercapacitor

Add a new member, capacitor type, to your struct Capacitor.

Update the capacitor type member of all elements of the array to a type of your choice. Update the displayCapacitorInfo function to print the capacitor type as well.

Saving/Loading from a File

Add (to capacitor.h/capacitor.c) the following functions:

- saveCapacitor: takes as parameters a capacitor and a filename and saves its member variables into the file given

- saveCapacitors: takes as parameters an array of capacitors and a filename and saves all capacitors into the file given, each capacitor on a separate line

- loadCapacitor: takes as parameter a filename and returns a capacitor. The function should populate the capacitor data from the given file.

Test your functions in your main program by:

- Saving the first capacitor into the file cap1.txt

- Saving the capacitor array into the file allCaps.txt

- Loading data from cap1.txt into a new capacitor variable

- Printing the values of the newly created capacitor to the screen

Handin

Submit through the handin system the following files: capacitorsInfo.c, capacitor.h, capacitor.c, makefile

The "handin" system has options to allow you to review your files online and to download them. You Should always verify that you submitted the correct files and they were received by the handin system. You can submit files as many times as you like for a particular assignment. Handin will only keep the last version of each file. Remember to submit your files prior to the deadline as you won't be able to use handin if the deadline has passed.

Reference no: EM131036844

Questions Cloud

Per quantitative performance measures : Dick works as the first-line manager of a team of sales persons at Dowson's Store, a leading clothes retail store. To motivate the sales agents in his team, Dick says that he will not assign weekend work and overtime to the top three sales agents, as..
Which differentiation strategy you would be following : Describe this innovative idea and Which segmentation technique you would be using to segment the market? And why?
Draw vertical lines to identify the slot boundaries : I am generally good with grammar, but these types of problems I have not attempted since high school. I have tried to work a few on my own, doing tons of research as a refresher, but I am not certain it is helping. I found a link for the pattern r..
Useful for predicting future job performance : Discuss some of the reasons why managers continue to use unstructured employment interviews despite the abundant evidence that they are not useful for predicting future job performance.?
C structs and enums : Protect your header using #ifndef directive. Define a struct with tag Capacitor that holds the following information about a capacitor: Model number (e.g. 11-123U), capacitance (e.g. 1000 uf), voltage (e.g. 2.5 V), cost ($6.50)
Indian managerial style and human resource practices : Typically, when international firms enter the Indian market, they quickly learn about the various ways in which a rigid caste system can affect business activities. Do you think it would be possible to uphold a U.S. management style in India? Which e..
Intentional infliction of emotional distress : Anthony Caruso lived in Mohican Historic Housing from 1998 to 2001, when he died. The Mohican Historic Housing Association was aware Margherita Del Core was Caruso’s next of kin, his sister. The trial court granted Mohican’s motion to dismiss, and De..
Use arbitration in resolving a contract negotiation impasse : Labor negotiators generally prefer to use arbitration in resolving a contract negotiation impasse because then they can control the outcome of the process. Before a contract is officially accepted, the union negotiating team submits the agreement to ..
Cognitive information processing pyramid : In chapter one, we are introduced to the Cognitive Information Processing Pyramid. Here we begin to focus on the bottom of the pyramid-(knowing about myself and knowing about my options). Use the information on page 9 “Cognitive Information Processin..

Reviews

Write a Review

Computer Network Security Questions & Answers

  Security of information in business organisations

Definitions and descriptions of the terms, 'integrity', 'availability' 'confidentiality', 'authenticity' and 'non-repudiation' in relation to the security protection of information assets in the chosen topic environment, i.e. what is it about thes..

  Creating a switchboard design with control buttons

Construct a detail report that will display all courses in alphabetical order, with course name and instructor name in a group header; the Social Security number, name, and telephone number

  Describe the purpose of a risk assessment

Describe the purpose of a risk assessment , risk scope and identify critical areas for an assessment.

  Differentiate threat from vulnerability

Consider the difference between qualitative and quantitative risk assessments; you should be able to distinguish the two. Differentiate threat from vulnerability and use this information as the basis for threat analysis and planning.

  Using cbc mode of operation what are consequences

Using CBC mode of operation what are the consequences of decrypting the cipher text if it has an error in the first bit of the first block C?

  Explain the implications of the risks and techniques

Briefly describe how computers and humans can pose risks to infrastructure assets. Explain the implications of the risks and techniques on critical infrastructure sectors

  Designate an appropriate class type for this attack

Designate an appropriate class type for this attack. Annotate your rules with comments describing what each component of the rule does, so other security specialists in your team can see how your rules are written.

  What was the volume of digital evidence

Cybersecurity or Digital Forensics- Select a real world event related to Cybersecurity or Digital Forensics. What was the volume of digital evidence

  Write about computer security affects you at school

Write about computer security affects YOU at school and in your personal life. You may be surprised at how many things you do that depend on some aspects of secure computer records and communications, like banking, grades, e-mail, timesheets, libr..

  Monitoring of a secure network design in an organization

Analyze strategies for maintenance and monitoring of a secure network design in an organization. Create recommendations for maintenance and monitoring tools to support maintenance of a secure network within an organization

  Providing security over data

The CIA triad (confidentiality, integrity, and availability) offers three (3) security tenets that allow data owners the framework to secure data. Considering your place of employment or your home computing environment, discuss in detail the prima..

  Distinguish physical security from logical security and

question 1 imagine a local financial company just expanded its operations into five branches connected over a broadband

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd