Professional Documents
Culture Documents
Basic Programing C++ Full
Basic Programing C++ Full
By Tadesse M (MSc).
Chapter 2
Programming
What is computer Programming?
Programming is the process of creating a set of direction that tell
programming languages.
What is computer Languages
A computer language is a method of communication
with a computer.
Computer programming language, any of various
but instead sit with it until they learn how it all came
together and they can even find new ways to work it to
provide better technologies.
As a programmer, you have to be ready to self-learn and
6, Algorithm Development:
skill of coming up with sequence of simple and human
ease of maintainability.
Possible benefits: the ability to re-use the same code
Process
A box indicates some particular operation.
Document
This represents a printout, such as a document or a report
Decision
A diamond represents a decision or branching point.
Lines coming out from the diamond indicates different
possible situations, leading to different sub-processes.
Find the largest among three different numbers
entered by the user
What is C++?
C++ was developed by Bjarne Stroustrup, as an
4) File Extension:
variables.
C++, however, doesn’t allow multiple declarations of
global variables.
why we learn of C++
C++ is one of the world's most popular programming
languages.
C++ can be found in today's operating systems,
Graphical User Interfaces, and embedded systems.
C++ is an object-oriented programming language
which gives a clear structure to programs and allows code
to be reused, lowering development costs.
C++ is portable and can be used to develop applications
that can be adapted to multiple platforms.
C++ is fun and easy to learn!
It’s used in a wide range of industries including
software and game development, VR, robotics, and
scientific computing.
Where we Uses of C++
There are several benefits of using C++ for developing
applications and many applications product based developed
in this language only because of its features and security.
Applications
It is used for the development of new applications of C++.
The applications based on the graphic user interface,
which are highly used applications like adobe photoshop and
others. Many applications of Adobe systems are developed
in C++ like Illustrator, adobe premiere and image ready and
Adobe developers are considered as active in the C++
community.
39
Games
This language is also used for developing games.
It overrides the complexity of 3D games. It helps in
optimizing the resources.
It supports the multiplayer option with networking.
uses of C++ allows procedural programming for
intensive functions of CPU and to provide control over
hardware, and this language is very fast because of which
it is widely used in developing different games or in
gaming engines.
C++ mainly used in developing the suites of a game
tool.
Animation
There is animated software, which is developed with the help
1. Simple
C++ is one of the most-simple languages when it comes
7. Compiler-Based
As no interpretation is done in C++ code it is considered to
store values.
Primitive Built-in Types
C++ offers the programmer a rich assortment of built-in
as well as user defined data types. Following table lists
down seven basic C++ data types −
Type Keyword
Boolean bool
Character char
Integer int
Valueless void
1 bool
Stores either value true or false.
2 char
Typically a single octet (one byte). This is an integer type.
3 int
The most natural size of integer for the machine.
4 float
A single-precision floating point value.
5 double
A double-precision floating point value.
6 void
Represents the absence of type.
7 wchar_t
A wide character type.
The following table shows the variable type, how much memory it takes to store the
value in memory, and what is maximum and minimum value which can be stored in
such type of variables.
Type Typical Bit Width Typical Range
char 1byte -127 to 127 or 0 to 255
float 4bytes
double 8bytes
Variable Declaration in C++
A variable definition tells the compiler where and how
much storage to create for the variable. A variable
definition specifies a data type, and contains a list of one
or more variables of that type as follows −
type variable_list; Here, type must be a valid C++ data
type including char, w_char, int, float, double, bool or any
user-defined object, etc., and variable_list may consist of
one or more identifier names separated by commas. Some
valid declarations are shown here −
int i, j, k;
char c, ch;
float f, salary;
double d;
Comments in C++
Program comments are explanatory statements that you
can include in the C++ code. These comments help
anyone reading the source code. All programming
languages allow for some form of comments.
C++ supports single-line and multi-line comments.
multi-line comments
C++ comments start with /* and end with */.
For example /* This is a comment */ /* C++ comments
can also * span multiple lines */
single-line comments
A comment can also start with //, extending to the end of
the line.
Assignment Operators in C/C++
Assignment operators are used to assigning value to a
variable. The left side operand of the assignment operator
is a variable and right side operand of the assignment
operator is a value. The value on the right side must be of
the same data-type of the variable on the left side
otherwise the compiler will raise an error.
Different types of assignment operators are shown below:
“=” operator
C++ cin
The cin object in C++ is an object of class istream.
It is used to accept the input from the standard input device i.e.
standard input stream (cin)
Usually the input device in a computer is the keyboard.