+ 1

C++ odd/even

could someone please make a code for this?? example output: enter 5 numbers: 8 9 10 1 3 odd numbers: 9 1 3 total of odd numbers: 13 even numbers: 8 10 total of even numbers: 18 thank you!!

15th Jul 2017, 3:53 AM
kenn lingcay
kenn lingcay - avatar
6 Respuestas
0
I think my brain's bleeding...
15th Jul 2017, 2:44 PM
kenn lingcay
kenn lingcay - avatar
0
nearly 2am here and I can't determine the right code, need sleep. here's my code :( #include<iostream> using namespace std; int main() { int numbers[5], sum=0; int n; cout<<"enter 5 numbers: "<<endl; cin>>n; for(int i=1;i<5;i++) { cin>>numbers[n]; } if(n%2==1) { cout<<"odd numbers: "; sum+=numbers[n]; } else if(n%2==0) { cout<<"even numbers: "; sum+=numbers[n]; } return 0; } still won't print all the odd and even numbers
15th Jul 2017, 5:50 PM
kenn lingcay
kenn lingcay - avatar
0
thanks a lot
15th Jul 2017, 11:22 PM
kenn lingcay
kenn lingcay - avatar