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 do c++ struct differs from the c++ class?
What is array in c++ pdf?
What is the difference between a type-specific template friend class and a general template friend class?
What is this weird colon-member (" : ") syntax in the constructor?
A mXn matrix is given and rows and column are sorted as shown below.Write a function that search a desired entered no in the matrix .with minimum complexity 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
Which operator cannot be overloaded c++?
What is the function of I/O library in C++ ?
How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Why is it difficult to store linked list in an array?how can you find the nodes with repetetive data in a linked list?
Explain the register storage classes in c++.
Write a struct time where integer m, h, s are its members?
What is difference between rand () and srand ()?
What is a storage class? Mention the storage classes in c++.
Differentiate between an array and a list?
What are static member functions?
Explain the use of virtual destructor?