0%
0 / 1 answered
Pre-Conditions Practice Test•1 Questions
Question
1 / 1
Q1
USING FUNCTIONS
Consider the following C++ code to perform the following subtraction:
9 - 6:
**#include <iostream>**
**using namespace std;**
**int main() {**
**int total = 0;**
**cout << "This code performs the following math operation: 9 - 6 = ";**
**total = sub(6,9);**
**cout << total;**
**}**
``
**int sub(int num1, int num2) {**
**return (num2 - num1);**
**}**
Is there anything wrong with the code?
USING FUNCTIONS
Consider the following C++ code to perform the following subtraction:
9 - 6:
**#include <iostream>**
**using namespace std;**
**int main() {**
**int total = 0;**
**cout << "This code performs the following math operation: 9 - 6 = ";**
**total = sub(6,9);**
**cout << total;**
**}**
``
**int sub(int num1, int num2) {**
**return (num2 - num1);**
**}**
Is there anything wrong with the code?