[SOLVED] COMP1410 Lab 1-Algorithm, Function

35.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon lab01-bfdzck.zip (2.1 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
5/5 - (2 votes)
  • Practice designing/implementing algorithms
  • Practice use of functions

Pre-requisite(s):

  • Read and review chapters 1-5.

Code and document the following functions using NON-RECURSIVE ITERATION only.

Test the functions by calling them from a simple interactive main() function using a menu, with different values used to select the choice of function. Overall, you should have one C program (call it Lab1.c) containing one main() function and 5 other functions, where the functions are called based on an interactive user menu:

1 Summation:Β Β  βˆ‘π‘›π‘˜=1π‘˜=1+2+3+β‹―+𝑛

n > 1; reject with error message otherwise

[Note that this sum is equal to n(n+1)/2.Β  DO NOT program the function – program the series.]

2 Factorial(0) = 1;

Factorial(n) = n * (n-1) * . . . * 2 * 1

Requirement: n >= 0; reject with error message otherwise

3 Fibonacci(0) = 0;

Fibonacci(1) = 1;

Fibonacci(n) = Fibonacci(n-1) + Fibonacci(n-2);

Requirement: n >= 0; reject with error message otherwise

4 gcd (x, y) = x, if y=0

gcd (x, y) = gcd (y, x MOD y), if y > 0

Requirement: x and y both > 0; reject with error message otherwise

5 Power(a,b) = π‘Žπ‘

Requirement:Β  a > 0, b > 0, b is an integer; reject with error message otherwise

 

How to document functions?

/*

Objective: Describe the function/its purpose briefly

Input: Describe the input parameters, or the assumptions/requirements for the function. Output: Describe the output of the function. (What does it return? What does it print, if anything?)

*/

EVALUATION OF WORK AND ATTENDANCE: Total 5 marks.

You need to show to your lab instructor the work you have completed for this lab assignment, generally in the form of a working program. The marks you will receive for the lab are made of two parts, the programming part and lab attendance. Do not email your work to the Instructor or to any teaching assistant.

 

Lab Work Mark: You will be evaluated based on your solution for the problem assigned, using the following scheme:Β  You must attend the lab and show your work in order to earn any of the following marks.

 

  • mark = No appreciable and relevant work done.
  • marks = Incomplete code / does not compile, with no, little or invalid documentation.
  • marks = Complete running program with no, little or invalid documentation.
  • marks = Incomplete code / does not compile, with suitable documentation.
  • marks = Complete running program with suitable documentation (minor errors may be accepted).
  • lab01-bfdzck.zip