LESSON 1 and 2 C
LESSON 1 and 2 C
LESSON 1 and 2 C
C++
was developed by Bjarne Stroustrup starting in 1979 at Bell Labs in Murray Hill, New
Jersey, as an enhancement to the C language and originally named C with Classes but later
it was renamed C++ in 1983.
C++ is a general-purpose programming language that was developed as an
enhancement of the C language to include object-oriented paradigm. It is an
imperative and a compiled language.
C++ is a statically typed, compiled, general-purpose, case-sensitive, free-form
programming language that supports procedural, object-oriented, and generic
programming.
C++ is regarded as a middle-level language, as it comprises a combination of both
high-level and low-level language features.
C++ is a superset of C, and that virtually any legal C program is a legal C++
program.
Note − A programming language is said to use static typing when type checking is performed during
compile-time as opposed to run-time.
Learning C++
4. Click Next
5. Click I Agree
6. Click Next
7. Click Install
8. Wait for the Codeblocks to Install
For more understanding of the history of c++ visit this video on youtube:
https://www.youtube.com/watch?v=SQHREey_Yuc
For more understanding of the codeblocks installation process visit this video on youtube:
https://www.youtube.com/watch?v=GWJqsmitR2I
C++ Basic Syntax
C++ is a general-purpose programming language and widely used nowadays for competitive
programming. It has imperative, object-oriented and generic programming features. C++ runs on
lots of platform like Windows, Linux, Unix, Mac, etc. When we consider a C++ program, it can
be defined as a collection of objects that communicate via invoking each other's methods.
Object − Objects have states and behaviors. Example: A dog has states - color, name,
breed as well as behaviors - wagging, barking, eating. An object is an instance of a class.
Class − A class can be defined as a template/blueprint that describes the behaviors/states
that object of its type support.
Methods − A method is basically a behavior. A class can contain many methods. It is in
methods where the logics are written, data is manipulated and all the actions are executed.
Instance Variables − Each object has its unique set of instance variables. An object's state
is created by the values assigned to these instance variables.
C++ Program Structure
Let us look at a simple code that would print the words Hello World.
C++ Keywords
The following list shows the reserved words in C++. These reserved words may not be
used as constant or variable or any other identifier names.
Trigraphs
o A few characters have an alternative representation, called a trigraph sequence. A
trigraph is a three-character sequence that represents a single character and the
sequence always starts with two question marks.
o Trigraphs are expanded anywhere they appear, including within string literals and
character literals, in comments, and in preprocessor directives.
Following are most frequently used trigraph sequences −
Whitespace in C++
A line containing only whitespace, possibly with a comment, is known as a blank line, and
C++ compiler totally ignores it.
Whitespace is the term used in C++ to describe blanks, tabs, newline characters and
comments. Whitespace separates one part of a statement from another and enables the
compiler to identify where one element in a statement, such as int, ends and the next
element begins.
For more understanding of the basic syntax visit this video on youtube:
https://www.youtube.com/watch?v=gscX6RGYd2k