Chapter 1: Getting started
This introduction frames C programming as giving a computer instructions to carry out specific tasks.
After this chapter you will be able to
- C as imperative programming. Explain why the introduction calls C programming imperative: a C program gives the computer orders to complete specific tasks.
- C as imperative language. Explain that a C program gives the computer orders about what to do, which is why C is called an imperative programming language.
- Formatted output with printf. Describe how the example calls printf to print lines on the terminal: quoted text supplies the output format, percent-prefixed specifiers mark where numbers go, and the following arguments supply those numbers.
- Compilation and platform portability. Explain why C source text must be compiled and how a correct C program can run across different platforms despite platform-dependent executable code.
- Diagnostics and clean compilation. Explain what the flawed example demonstrates about compiler diagnostics, warnings, and whether an executable is produced.
Section by section
Introduction
This introduction frames C programming as giving a computer instructions to carry out specific tasks.
- C as imperative programming: Explain why the introduction calls C programming imperative: a C program gives the computer orders to complete specific tasks.
Why it matters: This gives you a starting point for understanding what the first C program is doing.
Key terms: C program, imperative programming
1.1 Imperative programming
The section introduces C as a way to give a computer instructions and uses a printf call to show how a program produces formatted terminal output.
- C as imperative language: Explain that a C program gives the computer orders about what to do, which is why C is called an imperative programming language.
Why it matters: This gives you a way to interpret the program as instructions rather than just text on a page. - Formatted output with printf: Describe how the example calls printf to print lines on the terminal: quoted text supplies the output format, percent-prefixed specifiers mark where numbers go, and the following arguments supply those numbers.
Why it matters: It connects a visible line of program text to the output the reader sees on the terminal.
Key terms: imperative programming language, orders, statement, call, function, printf, arguments, string literal
1.2 Compiling and running
This section explains how C source text becomes an executable, why portability requires care, and how compiler diagnostics help identify flawed programs.
- Compilation and platform portability: Explain why C source text must be compiled and how a correct C program can run across different platforms despite platform-dependent executable code.
Why it matters: It explains both why you need a compiler and why one successful run is not proof that a program is portable. - Compile and run command: Describe the roles of the source file, compiler, output-file option, and warning option in the section’s example, and what happens after compilation succeeds.
Why it matters: These command parts let you tell the source program apart from the executable the compiler creates. - Diagnostics and clean compilation: Explain what the flawed example demonstrates about compiler diagnostics, warnings, and whether an executable is produced.
Why it matters: An executable is not evidence that the source is correct, so diagnostics deserve attention.
Key terms: compiler, binary code, executable, platform, portable, c17, -Wall, -o, source file, diagnostic
1.3 Summary
Where this is used later
- Statements (chapter 2) · The discussion of statements develops how programs express instructions.
- (chapter intro) (chapter 2) · The earlier C example identified as Listing 1.1.
- Formatted output (chapter 8) · The later treatment of formatted output builds on this introductory printf example.
- (chapter intro) (chapter 22) · Familiarity with compiling programs using a development toolchain
Concepts explained in this chapter
- C++C++ is a general-purpose compiled programming language with C compatibility and object-oriented, generic, and low-level programming features.
- command-line argumentA command-line argument is a string value supplied to a program when it is invoked from a command-line environment.
- compilerA compiler implementation is the concrete software realization of a compiler that translates source programs according to a language's rules.
- portabilityPortability is the ability of software to operate across different platforms or computer architectures with little or no change.
- imperative programmingA programming paradigm in which programs specify computations as ordered commands that change program state or direct execution.
- format stringA format string is a character sequence containing literal text and format specifiers that controls formatted output conversion.
- callA function call is an expression or statement that requests execution of a function with supplied arguments.
- string_literalstring_literal is a book-specific function-like macro that accepts a string literal by requiring adjacent empty string literals in its replacement.
- escape sequenceAn escape sequence is source-code notation beginning with a backslash that encodes a character or special value.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.
