find the errors\neach of the following programs has some errors. locate as many as you can.\n28. using…

find the errors\neach of the following programs has some errors. locate as many as you can.\n28. using namespace std;\nint main ()\n{\n double number1, number2, sum;\n cout << \enter a number: \;\n cin << number1;\n cout << \enter another number: \;\n cin << number2;\n number1 + number2 = sum;\n cout \the sum of the two numbers is \ << sum\n return 0;\n}
Answer
Explanation:
Step1: Identify syntax - case sensitivity
In C++, cout and cin are case - sensitive. Here, Cout and Cin are misspelled. They should be cout and cin.
Step2: Identify assignment operator usage
The statement number1 + number2 = sum; is incorrect. In C++, the left - hand side of an assignment operator = must be a modifiable lvalue. Here, number1 + number2 is an expression (rvalue), not a modifiable lvalue. It should be sum = number1 + number2;.
Step3: Identify missing semicolon
The statement Cout "The sum of the two numbers is " << sum is missing the << operator before the string literal and also a semicolon at the end of the statement. It should be cout << "The sum of the two numbers is " << sum << endl; (adding endl is optional but a good practice to flush the output buffer and move to the next line).
Answer:
CoutandCinshould becoutandcin.number1 + number2 = sum;should besum = number1 + number2;.Cout "The sum of the two numbers is " << sumshould becout << "The sum of the two numbers is " << sum << endl;.