0
An array have ten elements print all even number and their sum in the array
3 ответов
+ 5
@Svengat: it should with a few corrections. ; () Ram will need to add a sum variable to it as well but yeah this should work fine.
+ 5
Something like this should do it. (using Svengats answer with corrections)
int sum = 0;
for(int i = 0; i < 10; ++i) {
if(arr[i]%2==0){
cout<<arr[i]<<endl;
sum+=arr[i];
}
}
This should also go along way to answering your two other (homework?) questions.
+ 4
for (i=0;i<10;i++){if arr[i]%2==0{cout<<arr[i]<<endl}}
//Hopefully the above strip works I am a really beginner at C++