COP 3223C Numeric Types Functions and Arrays in C Project

COP 3223C Numeric Types Functions and Arrays in C Project

COP 3223C Numeric Types Functions and Arrays in C Project

ORDER NOW FOR CUSTOMIZED AND ORIGINAL ESSAY PAPERS 

I need someone do finish this by following all of the instructions laid out in the assignment paper. COP 3223C Numeric Types Functions and Arrays in C Project

 

Homework 1 COP 3223C Introduction to Programming with C, Section 0V06 Spring 2021 1 DESCRIPTION For this assignment you will be working with numeric types, functions, and arrays. You will write three functions named SumOfDigits, PrintDivisors, and GetBinomialCoefficient. All three functions should be in a single C source file named homework1.c. The descriptions of each function are listed below in the Function Requirements Section. Feel free to implement additional “helper” functions as you see fit. 2 DELIVERABLES A single C source file named homework1.c must be submitted to Webcourses by the assignment deadline (posted in Webcourses). 3 GRADING RUBRIC Uses correct filename (See Deliverables) Includes appropriate header comment (See Style Requirements) Uses tasteful comments (See Style Requirements) Follows all style requirements (See Style Requirements) Required functions work correctly and produce correct output (See Function Requirements) Total 5 pts 5 pts 10 pts 20 pts 60 pts 100 pts Page 1 of 5 4 SUPER IMPORTANT INFORMATION  Sharing code or posting assignment details in public places will be considered academic dishonesty and will result in an automatic 0 grade for this assignment. Feel free to have high level discussions about the assignment and your solution with your classmates. In general, discussions about the assignment are encouraged if they are only with students actively enrolled in this course and do not include any sharing of code.  Copying source code from the internet or other sources other than your own brain will be considered academic dishonesty and will result in an automatic 0 grade for this assignment.  Your source file must be named correctly to receive full credit. See Deliverables for the required filename. If you submit your file multiple times to Webcourses an additional “-n” will be added to the end of the filename (example: homework1.c, homework1-1.c, homework1-2.c, etc.). Files with this suffix will also be accepted.  Your source file must contain the exact method signatures listed in Function Requirements to receive full credit.  Your source file must compile and run to receive credit. Submissions that do not compile will receive an automatic 0 grade.  Submissions that print extra information to the console will not receive full credit. Your submission should only produce console output if specifically requested in Function Requirements. Page 2 of 5 5 FUNCTION REQUIREMENTS The source file you submit should contain the following functions: unsigned int SumOfDigits(unsigned int n) Description: Develop a function that takes a non-negative integer n as a parameter and returns a non-negative integer containing the sum of n’s digits. For example, if the input parameter n was 17239 then the output of this function should be 1 + 7 + 2 + 3 + 9 = 22 Example input: n = 17239 Example output: 22 void PrintDivisors(unsigned int n) Description: Develop a function that takes a non-negative integer n and prints out all its divisors, that is all numbers m between 1 and n (including those) such that n is divisible by m. The divisors should be printed out in the increasing order. COP 3223C Numeric Types Functions and Arrays in C Project
Example input: n = 3150 Example output: Divisors of 3150: 1, 2, 3, 5, 6, 7, 9, 10, 14, 15, 18, 21, 25, 30, 35, 42, 45, 50, 63, 70, 75, 90, 105, 126, 150, 175, 210, 225, 315, 350, 450, 525, 630, 1050, 1575, 3150 unsigned long GetBinomialCoefficient(unsigned int n, unsigned int m) Description: Develop a function that takes two positive integers n and m (n ≥ m) as parameters and returns their binomial coefficient: n n! ( )= m m! (n − m)! Note that the factorial of 𝒏 is equal to 𝑛! = 1 ∙ 2 ∙ 3 ∙ ⋯ ∙ (𝑛 − 1) ∙ 𝑛, and also 0! = 1. Example input: n = 5, m = 2 Example output: 10 Hint: Take a look at the factorial example from class BONUS QUESTION (20 extra points): Can you do better without computing three factorials? Look at the formula above and see how you can optimize computations (which will also reduce the possibility of overflow for the output type unsigned long). Page 3 of 5 6 STYLE REQUIREMENTS  Header Comments: Submissions must include a header comment of the following form on the very first line of the file: 0 |// 1 |// NID: 2 |// “” 3 |// , < Current Semester>  0 |// John Smith 1 |// NID: jo123456 2 |// Homework 1 “homework1.c” 3 |// COP 3223C Section 0V06, Spring 2021 Function Comments: All required functions must have a comment directly above them that describes what they do. Function comments should include a description of a function’s expected inputs and expected outputs: 0 |// Takes a non-negative integer n as input and returns n! where 1 |// n! is a positive integer and n! = 1 * 2 * 3 * 4 * … * n 0 |int factorial(int n) 1 |{ 2| … 3 |}  Tasteful Comments: You should add comments throughout your code that make the code easier to read. Be careful when adding tasteful comments to your code; only lines that need tasteful comments should have them. Tasteful comments should be placed directly above the line or block of code they describe, or on the same line as the line they describe: 0 |void foo(int n) 1 |{ 2 | int i, a = 0, b = 1; 3 | 4 | // You can put comments like this 🙂 4 | for (i = 0; i < 10; i++) 5 | { 6 | a++; // You can put comments like this 🙂 7 | b–; 8 | 9 |// You sould NOT put comments like this (bad indentation) 10 | a = a * b; 11 | } 12 |}  Please also avoid very long comments. Comments must usually fit one visible line in the editor. Whitespace: Variables, values, and operators should be separated by a single space in your code: 0 |void foo(int n) 1 |{ 2| int a = 0, b = 1; 3| 4| a = a + 1; // This is allowed 5| b=b+1; // This is NOT a good style because there are no spaces between b, =, +, and 1 6 |} Page 4 of 5 Whitespace: Your submission should include blank lines as needed to make your code easier to read. In general, you should include blank lines to separate statements that preform different tasks: 0 |void foo(int n) 1 |{ 2| int i, a = 0, b = 1; 3| 4| for (i = 0; i < 10; i++) 5| { 6| a++; 7| b–; 8| } 9 |}  // Initialize some variables // Blank line for readability // For loop performing a new task Indentation: Submissions must have consistent indentation. This means that any two lines of code inside the same code block (functions, if statements, loops, etc.) must have the exact same indentation: 0 |void foo(int n) 1 |{ 2| int i, a = 0, b = 1; // Lines 2 and 4 must have the same indentation 3| 4| for (i = 0; i < 10; i++) 5| { 6| a++; // Both of these lines are in the same for loop, 7| b–; // so they have the same indentation. 8| } 9 |}  Indentation (Contd.): When a nested code block is created (like a loop inside a function), all lines of code inside the nested code block should be indented one more time than the nested block’s container (I know that sounds confusing, so take a look at the example below): 0 |void foo(int n) // This line has an indentation of 0 (no indentation) 1 |{ 2| int i, a = 0, b = 1; // This line has an indentation of 1 because it is inside of foo 3| 4| for (i = 0; i < 10; i++) // This line has an indentation of 1 because it is inside of foo 5| { 6| a++; // Both of these lines have an indentation of 2 7| b–; // because they are inside a for loop inside of foo. 8| } 9 |} Page 5 of 5