hello, i have question , i have an array a[4];
and i did the function belw first one to ask the user to put the elemints then find the sum ,my question is i want to send the alemints that the user put it to the malti funtion without repeat read funtion in malti funtion , how i do it ??, please answer me i have exam.
thank you so much
it is not right now but tomorow and this an example to help me to understand what i should do for tomorow , you miss understand me and i know my english is not perfect sorry
sum=sum+a[4]; is wrong: you are adding the fifth value of the array every time (also when it has not been read yet). You should do sum=sum+a[i];
Then you should not repeat the read function. Instead you should have a read function that fills your array, then pass your array to other functions that process its values and do the calculations you want.
oh thank you i did not noticed this mistake , yes how can i pass the array after the user put it to other function ? for example i did the sum and i return a[i];
then how can i send the a[i];it to malti funtion in this example ?
can you write please how it will be ?
acctlully i understand ,but how i do it inside the function but not in funtion call.
here is another example ,
i have array a[10], and in the first funtion i have to ask the user to input 10 number , and i have to send it to the scound funtion and categorize them itno even and odd , then i have to send it to print funtion to print it on screen . this is my tried but i know it wrong becuse i dont know how to send the array to other funtion , if you can please help me to understand how . thank you
Ok, first of all what exactly is your spolit function doing? It calculates the sum of the even and the odd elements, then... what? The variables "even" and "odd" only live inside that function: they are never returned to other parts of the code and are completely useless.
Then why do you call spolit inside your print function? This should only print the elements of the array... nothing more than this.