Lecture 3
What is a string in C++ ?
- stores text, such as "Hello World". String values are surrounded by double quotes
What is C++?
C++ is a middle-level programming language
Difference between C and C++
C++ was developed as an extension of C, and both languages have almost the same syntax.
Qualities of Good Algorithms
Input and output should be defined precisely. Each step in the algorithm should be clear and unambiguous Algorithms should be most effective among many different ways to solve a problem. An algorithm shouldn't include computer code. Instead, the algorithm should be written in such a way that it can be used in different programming languages.
String Concatenation
The + operator can be used between strings to add them together to make a new string. This is called concatenation.
What does C++ consist of?
The core language giving all the building blocks including variables, data types and literals, etc. The C++ Standard Library giving a rich set of functions manipulating files, strings, etc The Standard Template Library (STL) giving a rich set of methods manipulating data structures, etc
What are constants?
When you do not want others (or yourself) to override existing variable values, use the const keyword (this will declare the variable as "constant", which means unchangeable and read-only):
What is a flowchart?
a diagram that graphically depicts the steps that take place in a program
What is an Algorithm?
an algorithm is a set of well-defined instructions to solve a particular problem. It takes a set of input and produces a desired output.
Declaring Variables
specify the type and assign it a value.
What is a double in C++ ?
stores floating point numbers, such as 19.99 or -19.99
What is an int in C++ ?
stores integers, without decimals, such as 123 or -123
What is a char in C++ ?
stores single characters, such as 'a' or 'B'. Char values are surrounded by single quotes
What is a bool in C++ ?
stores values with two states: true or false