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 / vaibhav nigam

@ Min Soo Kim

i will use your concept but in a better way like:
there is no need to make any f() function to calculate
factorial.

some lines of code:

main()
{
int a,b;
cin >> a;
bool check=1; //'1' for correct and '0' for wrong answer
if(a!=1)
check=0;
else {
for(int i=2; i<=1000; i++) {
cin >> b;
if(a*i!=b) {
check=0;
break;
}
a=b;
}
}
if(check)
printf("correct");
else
printf("wrong");
}


// since factorial(1000) is a very large value, so another
container can be used but logic remains same

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is meant by a delegate?

606


What is a stack? How it can be implemented?

694


What is pure virtual function?

623


State the difference between delete and delete[].

577


How do you clear a set in c++?

605






What are separators in c++?

622


Write my own zero-argument manipulator that should work same as hex?

585


What is the difference between structures and unions?

580


Define a pdb file.

638


Differentiate between late binding and early binding.

640


What is virtual base class?

567


What is binary search in c++?

568


How do you print a string on the printer?

573


Can you be bale to identify between straight- through and cross- over cable wiring? And in what case do you use straight- through and cross-over?

563


Show the declaration for a static member variable.

524