dimanche 18 novembre 2018

finding sum of even numbers from 1 till 100, question about the count?

i was wondering why did we use count++ instead of for example count += 0 to count the number of even numbers?

 #include <iostream>
    using namespace std;
    int main()
    {
        int count = 1;

        for (int i = 0; i <= 100; i++)
        {
            if (i % 2 == 0)
                count += 0; // why it will give me only 1? as output
            else
                continue;
        }
        cout << "num of even: " << count << endl;

        system("Pause");
        return 0;
    }

Aucun commentaire:

Enregistrer un commentaire