C++ program to print the floating-point numbers
kw.cpp
#include <iostream>
using namespace std;
int main()
{
    float i = 1;
    do
    {
        cout<<i<<"\n";
        i = i + 0.1;
    } while (i <= 2.1);
    return 0;
}
Output
kodingwindow@kw:~$ g++ kw.cpp
kodingwindow@kw:~$ ./a.out 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2 kodingwindow@kw:~$
Advertisement