Each data type stores a specific type of value, such as characters, integers, and floating-point numbers, which is used when defining variables and constants in C code. Knowing the data types available, and when and how to use each, is an important step to writing any C language program.
- Programming is about input and output. The old IO, you sing about at computer camp. Input is received, modified, and then output. The stuff that's input, modified and output is data. In the C language data is classified into four types. The data type describes what kind of information is used in your code. The four basic C data types are shown here. Char, to store a single character or byte of information, Int, to store integer or whole number values, and float and double to store real numbers, Which are fractions, are very large or very small values. A float is a single precision value, accurate to 8 digits. And a double is a double precision value accurate to 16 digits. These data types also have qualifiers which can refine the data's scope. For example, the signed qualifier is the default, meaning that an integer value stores both positive and negative numbers, an unsigned qualifier means the integer stores only positive values. In this exercise file, Four data types are listed. Lines 5 through 8 they are characters C, integer I, float F and double D. The scanf functions in the main body of the code, read the input of the different types. The first argument in the function is the data type. The second is the address of the specific variable. Lines 21 to 24 output the results. Nothing is processed here. The information just goes in and it comes back out. Build and run and all types of values. A, for the character. 42, for an integer. Small value one quarter, and the large value, let's do 2.56e12. And you see the results output here. The void data type is also available, void for no data. This type comes into play for allocating memory and referencing functions that return no value or accept no arguments. Unlike other programming languages, C has no string data type. Instead, an array of characters represents a string. This code declares an empty character array at line 5. The data type is char, characters. The name is buffer and it stores room for up to 32 characters. The F gets function at line 8, reads from standard input stdin up to 32 characters, storing them in the buffer. Then line 9 outputs the buffer. Build and run and all type my name. And you see, my name was stored and output. Obviously, a lot goes on with C data types, input, output variables, and all that. But at the core, the C language has these four data types, which describe information used in your code.
- Writing your first C program
- Working the C development cycle
- Adding comments to code for clarity
- C language data types
- Declaring variables
- Making new data types
- Typecasting variables
- Using math, assignment, and logical operators
- Creating for and while loops
- Nesting loops
- Creating functions
- Returning values from functions
- Passing arguments to functions
- Creating recursive functions
Skill Level Intermediate
C: Data Structures, Pointers, and File Systemswith Dan Gookin2h 57m Intermediate
1. The Fundamentals of C
2. Variables and Values
3. Operators and Math
4. Decisions and Loops
Next steps1m 38s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.