Write your question here.
Hi im just starting out c++ and my teacher is not helpful at all and i really want to learn. The issue i am having is im trying add all the numbers that that were not skipped and add all the even and odds that are left over, so fat i managed to print the numbers i did not skip.
11. add up all the numbers from min to max, skipping multiples of ETC, and show the total odd numbers, total even numbers, and the grand total, average odd, average even, and average of all the numbers.
1 2 3 x 5 6 7 x 9 = 33
2 6 = 8
1 3 5 7 9 = 25
---- Manipulating TWO variables in a loop: -----
Imagine the numbers between min and max in a row...
in another row, imagine odd numbers between min and max
min: 1
max: 10
1 2 3 4 5 6 7 8 9
1 3 5 7 9
#include <iostream>
using namespace std;
int main()
{
int max = 0;
int min = 1;
int number1 = 0;
int number2 = 0;
int etc;
int odd;
int even;
cout<<"Min number is : "<< min <<endl;
cout<<"Enter max number: ";
cin>>number2;
cout<<endl<<endl;
cout << "The sum of even numbers is: "<< even_sum << endl;
cout << "The sum of odd numbers is: "<< odd_sum <<endl;
cout << "The grand total is: "<< odd_sum + even_sum << endl;
The title of your post is "looping drills" but I'm not seeing any loops in your code. I think you need FOR loops.
for example, a for loop declares the starting value, the loop until condition, and the increment or sentinal value to end the loop.
1 2 3 4
total=0;
for (int x=0; x<10;x++){ //this will loop 10 times, from 0 to 9. It stops when x=10.
total+=x; //this will add the value of x to total (0+0, 0+1, 1+2, 3+3, 4+6) and so one
}