Given a simple program designed to take inputs of integers
from 1-1000 and to output the factorial value of that
number, how would you test this program? You do not have
access to the code. Please be as specific as possible.

Answer Posted / min soo kim

If the function that takes integers from 1 to 1000 can be
considered function f(n), then we could write the following
line of code

int i = 0;
int is_incorrect = 0;
for(i = 2; i <= 1000; i++)
{
// This is a simple for loop to divide a f(n) factorial
with f(n-1) factorial, which would give the result of n.
if(f(i) / f(i-1)) !- i)
{
is_incorrect = 1; // Mark the flag as incorrect, since
we did not get the value that we want.
break;
}
}

Is This Answer Correct ?    17 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

daily Routine of father

1120


Why do we use setw in c++?

840


What is c++ flowchart?

955


Is recursion allowed in inline functions?

780


Write about the scope resolution operator?

772






What is operator overloading in c++ example?

832


Write a c program for binary addition of two 8 bit numbers.

3860


What is switch case in c++ syntax?

812


What is a driver program?

828


What is an inline function in c++?

829


Define a nested class. Explain how it can be useful.

823


What's the "software peter principle”?

806


Can I create my own functions in c++?

789


What is the difference between prefix and postfix versions of operator++()?

792


What is &x in c++?

752