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

  Formulas and charts of the investigation.

Epidemiological data and operational information about outbreaks is dynamic and changes rapidly. I have to develop a comprehensive Event Management System to manage critical information about an outbreak using.

  Security mechanisms needed to protect the dms systems

Analyze the security mechanisms needed to protect the DMS systems from both state employees and users accessing over the Internet

  Descripe what is web cache about secure computer network

Descripe what is each topic about secure computer network and why its important? Describe these topics to somone that has no knowledge in computer networks to deliver the idea to him?

  Draft compliance matrix and compliant proposal to rfp

Create a compliance matrix and prepare a FAR-compliant proposal in response to the RFP from Assignment 2. Note: You may create and /or assume all necessary assumptions needed for the completion of this assignment.

  Write the symbolic logic for the 3des decryption

How would you protect the passwords on your system using some of the mechanisms we have studied? Discuss implementation strategies and explain your decisions.

  Research and report upon the problem of supply chain risk

For this paper, you will research and report upon the problem of Supply Chain Risk as it pertains to the cybersecurity industry.

  Explain how outsourcing can be used for risk transference

Describe how outsourcing can be used for risk transference. Name and briefly describe two examples/cases of risk transference in Australia that you believe this type of risk management helps to protect organisations interest. How is an application ..

  Victim of cyberstalking while using social networking?

victim of cyberstalking while using social networking?

  What are few security compromises that were faced in past

What are the few security compromises that were faced in the recent past due to lack of internet and e-Commerce security competencies?

  Project management to suppress the dissemination

The general method is to encourage timely communication of news to project stakeholders. However, can you envisage conditions where it may be necessary,

  Security of information in government organisations

Complete a research essay about information security. The research provides you with the opportunity to complete research and demonstrate knowledge of information security from a theoretical perspective

  Describe the need for information security

Describe the need for information security, The potential issues and risks that exist and what benefits they can gain from the new wireless fidelity (W-Fi) project

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