Chapter 1: Introduction to C

Ace your homework & exams now with Quizwiz!

C

(1978) Brian Kernighan and Dennis Ritchie at AT&T Bell Labs created the language after another language called B and became a dominant programming language from 1980s and 1990s

instruction

each calculation

logic errors

errors that cause the output of the program to be incorrect. (bug)

run-time errors

errors that cause the program to terminate (or end) prematurely

syntax errors

errors with how the code is written

Good practice: compiling frequently

especially for new programmers, is to compile after writing only a few lines of code, rather than writing tens of lines and then compiling. (New programmers commonly write tens of lines before compiling, which may result in an overwhelming number of compilation errors and warnings and logic errors that are hard to detect and correct.)

Good practice: fixing first error

focus on fixing just the first error reported by the compiler and then recompiling. (The remaining error messages may be real but are more commonly due to the compiler's confusion caused by the first error and are thus irrelevant.)

variables

referring to data (like x, y, z)

single-line comment

starts with // and includes all the following text on that line.

multi-line comment

starts with /* and ends with */, where all text between /* and */ is part of the comment. (also known as a block comment)

high-level languages

support programming using formulas or algorithms, so a programmer could write a formula

compile-time error

syntax error by the compiler

comment

text a programmer adds to code to be read by humans to better understand the code, but ignored by the compiler.

string literal

text in double quotes (Example:) --> (" ")

processors

were created to process (aka execute) a list of desired calculations

compilers

which are programs that automatically translate high-level language programs into executable programs.

semicolon

at the end of every line, like a period in a sentence.

assembly

automatically translate human readable instructions

bits

binary digits of 1's and 0's.

good practice: compile warnings

compile without or print more warnings.

program

consists of instructions executing one at a time. (input, process, output)

printf

construct supports output.

computational thinking

creating a sequence of instructions to solve a problem

whitespace

refers to blank spaces (space and tab characters) between items within a statement and blank lines between statements (called newlines).

C++

(1985) Bjarne Stroustrup published a book describing a C-based language, adding constructs to support a style of programming known as object-oriented programming, along with other improvements.

input

A program gets data, perhaps from a file, keyboard, touchscreen, network, etc.

process

A program performs computations on that data, such as adding two values like x + y.

output

A program puts that data somewhere, such as to a file, screen, network, etc.

Algorithm

A sequence of instructions that solves a problem

Programmer: create a solution

Before writing a program.

unclear error messages

Compiler error messages are often unclear or even misleading. The message is like the compiler's "best guess" of what is really wrong.

machine instructions

Instructions represented as 0s and 1s

Whitespace and precise formatting

Programming is all about precision. Programs must be created precisely to run correctly. (Attention to Detail)

scanf ("%d", &x)

The following statement gets an input value and puts the value into variable x: (The & before x is necessary to indicate where in memory the read value should be stored)

Conventions: whitespace

Use blank lines to separate conceptually distinct statements. Indent lines the same amount. Align items to reduce visual clutter. Use a single space before and after any operators like =, +, *, or / to make statements more readable.

newline

\n, in the string literal starts a new output line

memory

a circuit that can store 0s and 1s in each of a series of thousands of addressed locations

warning

a report by the compiler that their is a possible logic error.

executable program

a sequence of machine instructions together form an executable program (sometimes just called an executable).

%d

in the string literal indicates that a decimal number (hence the d) should be printed there, with that number being the value of the variable that follows.

Good practice: whitespace

is to deliberately and consistently use whitespace to make a program more readable.


Related study sets

Chapter 34: Nursing Care of the High Risk Newborn, Chapter 36: Hemolytic Disorders & Congenital Abnomalies, Chapter 35: Acquired Problems of the Newborn

View Set

Lesson 1: Read and Respond Game Design I A Unit 1: Games and Gameplay

View Set

Vocabulary Workshop Level H Units 13-15

View Set

Macroeconomics Chapter 13: Fiscal Policy (Final)

View Set

Copy of PA--las vacaciones Spanish 2: 09302019

View Set

Chapter 25 MC Questions (BIOL 1307)

View Set