Can anyone make sense of this?

I'm taking C++ in college and my professor is foreign and can not speak English very well. He wrote all of this on the board for us to do but I'm really not sure what he wants us to do. I believe it is a few different programs. Can anyone make sense of this?

even| for (int i= 0; i <= 100; i +=2)
| {
tot t= i;

}

odd for (int i = 1; 1 <= 100; i+=2)
{
totodd +=i;
}
These are all different programs
seperate appropriately.


float ave;
int tot = 0;
int c = 0;

for (int i = 0; i <= 100; i++)
{
c++;
cout << i;
tot +=i;
}

cout << "count is # y time goes through loop = "; << c;
ave = tot/c;


do
i+=2;
while(1 <=100)

for (0;0;0;)?(not sure if this is relavent)

for (int i = 0;i<= 100; i++)
{
if (i mod2==1)
totodd+=i;
else
toteven +=i;
}
totall = totodd + toteven;


-c =0;
-n = 0;

while (cin>>n)
{
tot += n;
n++;
}

n=0;
while (n<=100)
{
n +=2;
toteven +=n;
}
closed account (28poGNh0)
This professor shows some potentiel

The first prog probab show all even numbers less that 100
the calculates its sum

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

int main()
{
    int toteven = 0;

    for (int i= 0; i <= 100; i +=2)
    {
        cout << i << " ";
        toteven += i;
    }cout << endl << "Total = " << toteven << endl;

    return 0;
}


The second prog probab the same show all odd numbers less that 100
the calculates its sum

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>
using namespace std;

int main()
{
    int totodd = 0;

    for (int i = 1; i <= 100; i+=2)
    {
        cout << i << " ";
        totodd += i;
    }cout << endl << "Total = " << totodd << endl;

    return 0;
}


The third prog calculates the sum of the numbers from 0 to 100 and caculates it average

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;

int main()
{
    float ave;
    int tot = 0;
    int c = 0;

    for (int i = 0; i <= 100; i++)
    {
    c++;
    cout << i << " ";
    tot +=i;
    }

    cout << endl << "Count is # y time goes through loop = " << c;
    ave = tot/c;
    cout << endl << "Average is : " << ave << endl;
}


The forth caculates the total of even numbers less than or equal 100 ,the total of odd numbers <= 100 ,then calculates the sum of both totals

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <iostream>
using namespace std;

int main()
{
    /*he shows you another way to do one of the above
    do
    i+=2;
    while(1 <=100)*/

    /*Dont be surprised this one is correcte too
    for (0;0;0)
        cout << "hello" << endl;*/

    int totall,totodd,toteven;

    for(int i = 0;i<= 100; i++)
    {
        if (i%2==1)
            totodd += i;
        else
            toteven +=i;
    }
    totall = totodd + toteven;
    cout << "The total of the odds and evens is : " << totall << endl;
}


The last part for me is garbadg
Best I can discern is to add all even or odd numbers in the range [0;100]. The rest is too disjointed to make sense of.
Thank you so much!!! I had no idea what he was trying to have us do.
For

-c =0;
-n = 0;

while (cin>>n)
{
tot += n;
n++;
}

the professor made a mistake somewhere. It looks like he wants to get an average of user inputs. Something like:

1
2
3
4
5
6
7
8
9
10
11
double sum = 0;
unsigned count = 0;
double n;

while (cin >> n)
{
  sum += n;
  count++;
}

cout << "The average of all inputs is " << (sum / count) << ".\n";

Hope this helps.
Topic archived. No new replies allowed.