Chapter 2 - Intro to Programming in C
Prompt
A printed line of string that tells the user to take a specific action
Identifiers
A variable name in C is any valid identifier, a series of characters consisting of letters, digits, and underscore that does not begin with a digit.
\a
Alert that produces a sound or visible alert without changing the current cursor position.
\\
Backslash (insert a backslash character in a string)
C programs
Contain one or more functions, one of which must be main. Every program begins executing at the function main. Functions can return information.
%d
Conversion specifier indicates that the data should be an integer
\"
Double quote (insert a double-quote character in a string)
Executable Statements
Either perform actions, or make decisions.
Memory Concept
Every variable has a name, a type, and a value. Whenever a value is placed in a memory location, the value replaces the previous value in that location. This process is said to be destructive.
\t
Horizontal Tab
Format Control String
Indicates the type of data that should be entered by the user
\
Is an escape character which indicates that printf is supposed to do something out of the ordinary. When encountering a backslash in a string, the compiler looks ahead at the next character and combines it with the backslash to form an escape sequence.
Preprocessor Directive
Lines beginning with # are processed by the preprocessor before compilation.
Comments
Lines that begin with // which do not cause the computer to perform any action when the program runs.
Variables
Must be defined with a name and a data type before they can be used in a program.
\n
Newline
String
Often called a character string, a message, or a literal.
&
Second argument of scanf which is called the address operator. When combined with a variable name, tells scanf the location in memory at which the variable integer1 is stored. The computer then stores the value that the user enters for interger1 at that location.
Output Statement
Something that instructs the computer to perform an action. Every statement must end with a semicolon.
Int main (void)
The prantheses after main indicate that main is a program building blocked called a function. The keyword int to the left of the main indicates that main returns an integer.
%
Treated by scanf and printf as a special character that begins a conversion specifier
Case Sensitivity
Uppercase and lowercase letters are different in C, so a1 and A1 are different identifiers.
Black Lines and White Space
Used only to make programs easier to read.
Scanf
Used to obtain a value from the user
x == y
x is equal to y
x >= y
x is greater than or equal to y
x > y
x is greater than y
x <= y
x is less than or equal to y
x < y
x is less than y
x != y
x is not equal to y