In the following C++ code snippet, there's a semantic error that results in incorrect results. Your task is to identify the semantic error and suggest a fix to produce the desired output.
Errors
Fix semantic errors
Report a typo
Sample Input 1:
3 4Sample Output 1:
Sum: 7Sample Input 2:
0 0Sample Output 2:
Sum: 0Sample Input 3:
0 1Sample Output 3:
Sum: 1Write a program in C++
#include <iostream>
int main() {
int a, b;
std::cin >> a >> b;
int sum = a - b;
std::cout << "Sum: " << sum << std::endl;
return 0;
}
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.