Add two more statements to main() to test inputs 3 and -1. Use print statements
ID: 3772089 • Letter: A
Question
Add two more statements to main() to test inputs 3 and -1. Use print statements similar to the existing one (don't use assert).
*Sample Program*
#include <iostream>
using namespace std;
// Function returns origNum cubed
int CubeNum(int origNum) {
return origNum * origNum * origNum;
}
int main() {
cout << "Testing started" << endl;
cout << "2, expecting 8, got: " << CubeNum(2) << endl;
/* Your solution goes here */
cout << "Testing completed" << endl;
return 0;
}
Must be done in C++. Please Bold your inputed code. Note that you can only write inside the //your answer comment. Break up comment when your answer is done to actually run it.
Explanation / Answer
#include <iostream>
using namespace std;
// Function returns origNum cubed
int CubeNum(int origNum) {
return origNum * origNum * origNum;
}
int main() {
cout << "Testing started" << endl;
cout << "2, expecting 8, got: " << CubeNum(2) << endl;
cout << "3, expecting 27, got: " << CubeNum(3) << endl;
cout << "-1, expecting -1, got: " << CubeNum(-1) << endl;
/* Your solution goes here */
cout << "Testing completed" << endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.