From the course: Complete Guide to C Programming Foundations

Unlock the full course today

Join today to access over 24,300 courses taught by industry experts.

Specifying integers and real numbers

Specifying integers and real numbers - C Tutorial

From the course: Complete Guide to C Programming Foundations

Specifying integers and real numbers

- [Instructor] Numbers in C come in two flavors. The INT data type stores integers, or whole number values, the float and double data types store real numbers, are those that contain a decimal portion or are very large or very small. Integer literals are written without commas as shown in line 5. For real numbers, always specify the decimal part. At line 6, float value, 0.25, is written as 0.25. At line 7, the real value 1 billion, no commas, has a trailing dot zero. This format, dot zero and zero dot inform the compiler that the literal value is a float or double number. This exercise file provides a quick test, run it. That'll type 100 million and it works. Now I'm going to run it again, but I'm going to type a comma. You see the value is truncated from what was input, not what you want. At line 10, the fgets function reads a string of characters into the buffer character array. The strtol function converts the string into a value stored in variable lv. This function doesn't…

Contents