Question: This assignment requires that you implement doctest based tests. There is already a skeleton Makefile with targets for main and tests as well as skeleton

This assignment requires that you implement doctest based tests. There is already a skeleton Makefile with targets for main and tests as well as skeleton .c .h and doctest.h files.

For each function specified in the main lab, add the code to funcs.h and funcs.cpp. You should call them from main but you also need to put in tests into tests.cpp.

I will test main but will only consider tests.cpp to determine if your functions area all working properly. You will have to make sensible decisions based on the assignment as to how many tests you need and what you should test for.

For reference, the doctest package and documentation can be found here: (chegg does not allow to post links so please go to github and then go to doctest/doctest to find the doctest code)

Note: Remember that your program (including tests) should not ask for any keyboard input. When run it should clearly show that all tasks are implemented and work.

Do the following 2 tasks:

This assignment requires that you implement doctest based tests. There is already

Using doctest.h as a file which is already given and a very long file, use it as a platform to make tests.cpp which is to determine if your functions area all working properly, and for each tasks add the function/code to funcs.cpp and funcs.h, while also calling it from main.

Some parts may be confusing, leave a comment if you do not understand, please make sure you complete the 2 tasks well and the code compiles and send a screenshot of output too, make sure all functions are implemented well.

Task A. Is divisible? Write a program numbers.cpp that defines a function boolisDivisibleby(intn,intd); If n is divisible by d, the function should return, otherwise return For example: isDivisibleBy(100,25)==trueisDivisibleBy(35,17)==false The program should also have a main function that tests your code. For example, it can ask the user to input two integer numbers and print Yes if the first number is divisible by the second, otherwise print No . Task B. Is a prime? A prime number is an integer greater or equal to 2 that is only divisible by 1 and by itself. The first few primes are: 2,3,5,7,11,13,17,19,23,29,31,37,41,43,47 N is a prime if and only if it is not divisible evenly by any of the numbers from 2 to N1. Let's implement this decision as a function. In the same program , add a function isprime(intn); The function should return if n is a prime, otherwise return . Change the function to test your new code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!