EE172_Lecture_1_Introduction_to_C++
EE172_Lecture_1_Introduction_to_C++
Introduction to MATLAB
Text/Reference Books
7
https://www.studytonight.com/cpp/
https://www.javatpoint.com/cpp-tutorial
8
Compiler / IDE
Coding C++
9
EE172
Computer Programming for
Engineers
Lecture 1:
Introduction to C++
10
Overview of C++
C versus C++
Structure of C++ Program
16
17
18
19
20
I/O header file
21
Standard I/O Functions in C++
22
26
What is
namespace std?
27
28
Error: conflicting declaration of ‘data’
29
30
In programming, we cannot have variables or functions with
the same name.
If the program has two identical identifier names, a compiler
has no way of knowing which version of the identifiers is
referred.
To avoid these names conflict, we use namespaces.
A namespace is used as additional information to
differentiate similar identifiers with the same name.
In essence, a namespace defines a scope.
31
32
33
Keywords in C++
34
Assignment Operator
Arithmetic Operator
Relational Operator
Logical Operator
Conditional Operator
Bitwise Operator
Assignment Operator
40
= A = 5 A = 5
+= A += 5 A = A+5
/= A /= 5 A = A/5
*= A *= 5 A = A*5
Arithmetic Operators
41
Operator Example
a + b Addition
a - b Subtraction
a * b Multiplication
a / b Division
a % b Remainder (modulo division)
++b Add 1 before using a variable
--b Subtract 1 before using a variable
Relational Operators
42
Operator Meaning
== Equivalent
!= Not equivalent
< Less than
> Greater than
<= Less than or Equal to
<= Greater than or Equal to
Logical Operators
43