Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that uses scanf within a nested for loop to read each year ( row ) of data breach counts by month (
Write a program that uses scanf within a nested for loop to read each year row of data breach counts
by month column into a D array from a file. The file contents are:
where rows are years and columns are number of data breaches in the US by month
Jan Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec You may use constants #define YEAPSOFDATA
and #define MONTHSPERYEAR for the loop conditions of the nested for loop and for the D array
dimensions. Once all monthly data breaches are read into your program, calculate, and print by year:
The total number of data breaches for each year
The month with the maximum data breaches for each year
The mean and standard deviation of monthly data breaches for each year
a Define a function for calculating the mean
i mean doubletotaldatabreachesperyeardouble MONTHSPERYEAR
b Calculate the standard deviation reference lecture WeekClass slide Figure
eviation where the mean, ifor month, &
Section D Requirements for Part b:
Create and edit a file named programbyourloginNamedatabreaches.c
a Note that all program source code files should end with a c extension
Use a multiline comment at the top of your c file that includes:
a Course and assignment number
b Your name
c Purpose of the program eg sentences
Use a comment in the main body above each step of your approachalgorithm Complete & test
one step at a time. Use functions to keep main function minimal & algorithm details in functions.
a eg A nested for loop to read in data from file and store
b eg Calculate and display annual totals
c eg Calculate and display month with max data breaches
d eg Calculate and display mean and standard deviations
Output floating point results displayed to the user formatted with decimal places
When your program is complete, use the goc command to compile it into an executable file
remember Im to link library for math.h for sqrt and then run the resulting executable file. Use
a multiline comment at end of your c file showing command line output from a sample run
Before doing a sample run, calculate by hand what the results should be for one of the years.
Show your work in a separate submission file. See Section F Submission.
Sample Run
:
: annual data breaches
: month of max breaches is May
: mean is and standard deviation is
output here
:
: annual data breaches
: month of max breaches is
: mean is and standard deviation is
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started