Question #47700

write a program to point the sum of six numbers with array and pointer
z
1

Expert's answer

2014-10-10T02:00:28-0400

Answer on Question #47700, Programming, C++

Problem.

write a program to point the sum of six numbers with array and pointer

z

Solution.

Code


#include <iostream>
using namespace std;
float sum(float *arr) {
    return arr[0] + arr[1] + arr[2] + arr[3] + arr[4] + arr[5];
}
int main() {
    float arr[6];
    // Input
    for (int i = 0; i < 6; i++) {
        cin >> arr[i];
    }
    // Output
    cout << sum(arr);
    return 0;
}


Result

1 2 5 1 2 3

14

http://www.AssignmentExpert.com/</iostream>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!
LATEST TUTORIALS
APPROVED BY CLIENTS