Commit 6b16883d authored by Daniel Duarte's avatar Daniel Duarte
Browse files

Homework contribution including the correction of the addition and...

Homework contribution including the correction of the addition and multiplication, and the creation of the sqrt function.
parent 52ab7c72
function c = addTwoNumbers_DanielDuarte(a, b)
% addTwoNumbers_DanielDuarte(a, b) returns the sum of a and b
c = a + b;
end
function c = multiplyTwoNumbers_DanileDuarte(a, b)
% multiplyTwoNumbers_DanielDuarte(a, b) returns the product of a and b
c = a * b;
end
function c = sqrt_DanielDuarte(b)
% sqrt_DanielDuarte(b) takes b and returns the square root of b
c = sqrt(b)
end
% Test file
c = addTwoNumbers_DanielDuarte1, 2)
% test if the addition function works as expected
assert(c == 3)
d = multiplyTwoNumbers_DanielDuarte(c, c)
% test if the multiplication function works as expected
assert(d == 9)
% Test for the homework
% test my sqrt function
assert(DanielDuarte(d) == sqrt(d))
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment