Question: C++ List any syntax or logic errors in the following program segments. a) int num1 = 0, num2 = 10, result; num = num +
C++ List any syntax or logic errors in the following program segments.
a) int num1 = 0, num2 = 10, result; num = num + 1; result = ++(num1 + num2); cout << num1 << << num2 << << result;
b) int num1, num2; char again; while ((again == y) || (again == Y)) cout << Enter two numbers: ; cin >> num1 >> num2; cout << Their sum is << (num1 + num2) << endl; cout << Do you want to do this again? ; cin >> again;
c) int num, bigNum, power, count; cout << Enter an integer: ; cin >> num; cout << What power do you want it raised to? ; cin >> power; bigNum = num; while (count++ < power); bigNum *= num; cout << The result is << bigNum << endl;
d) int numCount, total; double average; cout << How many numbers do you want to average? ; cin >> numCount; for (int count = 0; count < numCount; count++) { int num; cout << Enter a number: ; cin >> num; total = total + num; count = count + 1; } average = total / numCount; cout << The average is << average << endl;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
