help me please

I need help to solve these questions
============================================================================
Write a program that uses a while loop to display all the even and odd numbers in a range of two inputs. Then calculate their sum and average.

Sample Run:
Enter a range of numbers: 3 16
The even numbers is: 4 6 8 10 12 14 16
Their sum is: 70
And their average is: 10

The odd numbers is: 3 5 7 9 11 13 15
Their sum is: 63
And their average is: 9

=============================================
Write a program that reads positive integers until a –1 is entered. Once input terminates, the program should report the total number of even numbers entered, the average value of the even numbers and the same for odd numbers. The program should also indicate which of the two categories (odd or even) has the highest count and the highest average.

Sample Run:
Please input the numbers, -1 to stop:
3
6
12
4
13
12
8
2
133
-1
There were 6 even numbers and their average was 7.33
There were 3 odd numbers and their average was 49.66
There were more even numbers than odd numbers
Odd numbers average is higher
=====================================================
4. Write a program that uses a While loop to calculate the sum of all the odd numbers less than an input value and not including the numbers 3 and 5. So if the user inputs 13 the program should compute the value of 1+7+9+11 and outputs the results.

Sample Run:
Enter a number: 13
Sum of odd numbers less than 13, excluding 3 and 5 is: 28

=================================================
Dont expect anyone to do your homework for you. Post what you have and where you got lost then we'll see what we can do
//try this and solve the remaining questions in this manner.

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main(){


int a,b,e,o,sum_even=0, sum_odd=0, i=0,j=0;

cout<<"Enter a range of Numbers:"<<endl;

cin>>a;
cin>>b;

if (a%2==0)
{
e=a;
o=a+1;
}
else
{
o=a;
e=a+1;
}

cout<<"The even numbers are:"<<endl;
while (e<=b) {

{ cout<<e<<" ";
sum_even=sum_even+e;
e=e+2;

i++;
}

};
cout<<"\nTheir sum is:"<<sum_even;
cout<<"\nand Their average is:"<<sum_even/i;

cout<<endl;
cout<<"\nThe Odd numbers are:"<<endl;
while (o<=b) {

{ cout<<o<<" ";
sum_odd=sum_odd+o;
o=o+2;

j++;

}

};
cout<<"\ntheir sum is: "<<sum_odd;
cout<<"\nand their average is:"<<sum_odd/j;

return 0;

}
Topic archived. No new replies allowed.