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
Explain the scope of resolution operator.
Explain stack & heap objects?
What does the nocreate and noreplace flag ensure when they are used for opening a file?
Difference between pass by value and pass by reference?
What is the best c++ book?
How did c++ start?
What do you mean by function and operator overloading in c++?
What is searching? Explain linear and binary search.
What do you mean by a template?
Which one is a preferred language C or C++? Why?
Can we sort map in c++?
What are shallow and deep copies?
What is pure virtual function?
What is type of 'this' pointer? Explain when it is get created?
How can virtual functions in c++ be implemented?