Answers for "c++ sum of even and odd numbers"

C++
0

c++ sum of even and odd numbers

//given the fact that it takes n of number
void sumEvenAndOdd(){
int n=0 , evenSum=0 , oddSum=0;
     int numbers[Size];
     cout<<"enters the number(N) of integers\n";
     cin>>Size;

     cout<<"Enter "<<Size<<" number/s:\n";
     for(int i =0 ;i< Size ; ++i){
        cin>>numbers[i];
     }
     for(int i =0 ;i<Size ; ++i){
        if(numbers[i]%2 ==0){
            evenSum += numbers[i];
        }
        else{
            oddSum += numbers[i];
        }
     }
     cout<<"the sum of even numbers is : "<<evenSum <<"\nthe sum of odd numbers is :"<<oddSum<<endl;
}
Posted by: Guest on December-30-2020

Code answers related to "c++ sum of even and odd numbers"

Browse Popular Code Answers by Language