C++ for statement Use float number as loop control

Description

C++ for statement Use float number as loop control

#include <iostream>

using namespace std;

int main()/*from  www  .j  av a  2s . c o m*/
{
    double x = 0.0;
    double i;

    for (i = 0.0; i <= 100; i+=0.1)
    {
        x += i;
    }

    cout << x << endl;

    return 0;
}



PreviousNext

Related