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

Is vector a class in c++?

799


Why would you use pointers in c++?

832


What is the precedence when there is a global variable and a local variable in the program with the same name?

886


Is c++ slower than c?

795


Can we delete this pointer in c++?

950


Why do we use iterators?

831


What are the four main data types?

811


Can malloc be used in c++?

801


What is a manipulator in c++?

939


How come you find out if a linked-list is a cycle or not?

782


Is python better than c++?

766


Explain the static member function.

926


Define a pdb file.

841


Explain class invariant.

775


What do manipulators do?

762