You are on page 1of 2

Programming Basics!

!
!

Basic Terms!
Algorithm -

!
Flowchart -
!
Pseudo code -
!
Program - set of instructions that a computer follows
!
Low level - machine language. Written in 1s and 0s
!

High level - Allow powerful complex programs without knowing how the CPU works. Ex. C++,
Java, Python

!
compiler - program that translates high-level into separate machine language program
!
interpreter - translates and executes the instructions in a high-level language
!
keyword - specific meaning and purpose in programming language
!
library - collection to pre-written code for specific purposes
!
syntax - set of rules that must be strictly followed when writing a program!
!
Basic structure of C++ program:!
!
#include <iostream> directive!
using namespace std ; namespace!

int main() beginning of main function!


{!
!
.!
!
return 0;!
}!

Basic C++ syntax: semicolon case-sensitiveness!


Statements end with a semicolon ;!
C++ is case sensitive!

Style: use of white space, variable names, constants, good function names, commenting, etc.!
Make code easier to read. Indents!

Importance of comments and two types of styles!


Brief notes in source. Used to document parts of the program!
Indicate purpose, describe variables!

single line and multiline comments!


!
Single line: Begin with // through to the end of line!
!
multiline begin with /* end with */!

Understand the concept of debugging, what a syntax error is, what a logic error is!
Mistake that doesnt let code run such as typo, missing puntuation, incorrect operator!
Basic Input and Output!
cout - display multiple items with a single cout system!
!
<< operators!
endl - start a new line!
Escape sequences - !
!
\n newline \t tab \
!
placed at the end of strings!

!
cin - read input from keyboar!
!

Variables and Artihmetic Expressions!


Variable - storage location i memory!
Must be declared!
Name and type!
Letters, digits, or underscore!
Cannot start with a digit!
Pothole - lowercase letters. words separated by underscores!
Camel - no spaces. Uppercase letters!

short - 2 bytes!
int / long - 4 bytes!
float - 4 byte floating point number with 7 digits!
double - 8 byte floating point with 15 digits accuracy!
char - 1 byte for characters!
string - string of text!
bool - 1 byte for true or false!

!
Variable initialization - assign a value when declared!
!
local variables - declared inside a function. belongs only to the function in which it is declared!
!
scope - part of the program in which the variable can be accessed!
!

You might also like