The program displays the sum of element 2 and element 4 of an array. Identify if it contains any error. If yes, locate and state the error. 1 #include using namespace std; 3 void compTotal(int a[])( for (int i = 0; i < 10; i++) { a[i] = a[i] * 2; 4 7 8 10 int main () ( 11 int total = 0, arr[10] = (1,2,3,4,5,6,7,8,9,0}; compTotal (arr); total = arr[1] + arr[3]; cout << "The total of element 2 and 4 is " <« total <« endl; 12 13 14 15 16 return 0; 17 Error in line 13: The indices of the array do not indicate the value in the element 2 and element 4. No Error. Error in line 4: The return datatype by the function compTotal(..) should be integer. Error in line 11: The declaration of a variable and an array should not be combined in one statement.
The program displays the sum of element 2 and element 4 of an array. Identify if it contains any error. If yes, locate and state the error. 1 #include using namespace std; 3 void compTotal(int a[])( for (int i = 0; i < 10; i++) { a[i] = a[i] * 2; 4 7 8 10 int main () ( 11 int total = 0, arr[10] = (1,2,3,4,5,6,7,8,9,0}; compTotal (arr); total = arr[1] + arr[3]; cout << "The total of element 2 and 4 is " <« total <« endl; 12 13 14 15 16 return 0; 17 Error in line 13: The indices of the array do not indicate the value in the element 2 and element 4. No Error. Error in line 4: The return datatype by the function compTotal(..) should be integer. Error in line 11: The declaration of a variable and an array should not be combined in one statement.
C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section: Chapter Questions
Problem 1PP: (Statistics) a. Write a C++ program that reads a list of double-precision grades from the keyboard...
Related questions
Question
Need this answer. Thank you
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 4 steps with 1 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr