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
How can I learn c++ easily?
What c++ is used for?
What is prototype for that c string function?
If I is an integer variable, which is faster ++i or i++?
What is split a string in c++?
What are special characters c++?
What is the main purpose of c++?
Are there interfaces in c++?
How to get the current position of the file pointer?
Differentiate between an array and a list?
How do you flush std cout?
What do the header files usually contains?
What do manipulators do?
How many different levels of pointers are there?
When does a name clash occur in c++?