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 - 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
-
-
-
-
Understanding C language data types3m 17s
-
(Locked)
Declaring variables2m 53s
-
(Locked)
Working with variables3m 4s
-
(Locked)
Exploring the printf() function3m 48s
-
(Locked)
Using constants2m 58s
-
Challenge: Making variables and constants53s
-
(Locked)
Solution: Making variables and constants1m 16s
-
(Locked)
Understanding variable scope3m 35s
-
(Locked)
Making new data types3m 25s
-
(Locked)
Specifying characters and strings3m 17s
-
(Locked)
Specifying integers and real numbers3m 55s
-
(Locked)
Typecasting a variable2m 20s
-
(Locked)
Chapter challenge: Adding variables and constants1m 10s
-
(Locked)
Chapter solution: Adding variables and constants2m 7s
-
-
-
-
-
-
-
-
-
-