+ 1

Where is wrong?

#include <iostream> using namespace std; int sum( int [ ],int ); void read( int [ ], int ); int main() { const int size=c; int a[size]; read( a , size); cout<<"SUM:"<<sum; } void read( int a[ ], size ) { int c,i; cout<<"how many number dou you want to enter? enter:"; cin>>size; do { cout<<"enter a["<<i<<"]:"; cin>>a[size]; }while(i<=size); } int sum( int a[ ] , int ) { int sum=0; for( i=0 ; i<c ; i++ ) { sum=sum+a[ size ]; } return sum; }

15th Dec 2019, 8:06 AM
Eliot
Eliot - avatar
2 Respuestas
0
And also Every time when you use a variable like size=c; Or cout<<sum; => you need provide the values (for c & sum) before using otherwise it give error or garbage values... Here 'sum' is a function so you need to call like sum(a,5);//5 is size ex. Run it playground and paste the link here.... If you don't get correct...
15th Dec 2019, 1:49 PM
Jayakrishna 🇮🇳