#include<iostream>
using namespace std;
int main(){
float even_sum= 0.0;
float odd_sum = 0.0;
for(int i=0; i<=20; i++){
if(i % 2== 0){
even_sum += i;
}
else{
odd_sum += i;
}
}
cout<<"The sum of odd numbers between 1 and 20 is\t"<<odd_sum<<endl;
cout<<"The sum of even numbers between 1 and 20 is\t"<<even_sum<<endl;
}
Comments
Leave a comment