# CS5001 Assignment 2 solved

\$35.00

## Description

5/5 - (1 vote)

Include all the specified functions in a file “assignment-2.c”. Include a main program that tests the functions by calling them with test data and printing the results returned by the functions. Include comments for the tests that describe their purposes. Label the output so someone else can understand it.

Provide a documentation block for for the file that includes the name of the file, its creation date, its author, and a brief description the file. Also provide a documentation block each function describing its purpose, parameters, and return values as appropriate. Check your file in to the CCIS GitHub repository 2018FACS5001SV/assignment-2-ccisID that was created by your instructor for your ccisID.

Function countCalls
Create a function unsigned int countCalls(bool reset) with a static unsigned in problem1Count to count the number of times the function is called. If called with false, the function increments problem1Count and returns 0. If called with true, the function resets problem1Count to 0 and returns the number of times the function was called since the last time it was reset.

Call this function from main several times with false to build up a count, then call it with true. Report the value returned from the function for each call. By way of example, if the function is called four times with false, it returns 0 each time. If then called with true, it returns 4 and resets problem1Count back to 0.

Function pi
Write a function double pi() that approximates value of pi to the precision of a double: 3.14159265358979 using an approximation technique that is the sum of the series
3 + 4/(2*3*4) – 4/(4*5*6) + 4/(6*7*8) – 4/(8*9*10) …

Use a loop to add successive tems of the series until the previous sum and sum with the next term are the same. Return this value as the result of the function.

Function daysInMonth
Write a function unsigned short daysInMonth(unsigned int month). The function takes a month number between 1 (Janauary) and 12 (December), and uses a switch statement to set a local unsigned short variable numDays to the number of days in any month (assuming 28 for February). Return numDays at the end of the function. If the input value is not a valid month number, return 0 from the function. Be sure to include this behaviour in your function documenation.