#include /* C version of code in Lecture 3 * * What is this code 'meant' to do? * What does this code 'actually' do? * * Remember Control-C is your friend. * * * Compile: gcc -o float1 float1.c * * ((NOTE:: you can compile with gcc float1.c * which makes the executable program a.out * * The "-o float1" option tells the compiler to save the * executable program as "float1" rather than "a.out" * * There are many other useful compile options, some of * which you should always use: -ansi -pedantic -Wall -Werror * -ansi tells the compiler to use the C standard language * (you should write code to the language standards) * -pedantic issue all the warnings demanded by strict ISO C * (it finds some non-ISO practices, but not all) * -Wall give language specific warnings * -Werror treat warnings as errors * * For this program, you might also like to compile it using * the compiler option: -Wfloat-equal * which is a compiler warning that is not included in -Wall * * So try: * gcc -ansi -pedantic -Wall -Werror -Wfloat-equal -o float1 float1.c * )) * * * Run: ./float1 */ int main(void) { float x; for (x = 0; x != 1.0; x += 0.1) { printf("%f\n", x); } return 0; }