Chapter 4

Printing different values of float

In C :

#include <stdio.h>

int main(void)
{
        float myfloat;
        myfloat = 123.456;
        printf("The value of a floating-point variable is: %f", myfloat);
}

In C++ :

#include <iostream>

int main()
{
        float myfloat;
        myfloat = 123.456;
        std::cout << "The value of d is: " << myfloat;
}