01_01_Intro
01_01_Intro
1. Intro
2. History
3. C vs CPP
4. Datatypes
5. Keywords
6. Input/output
7. Basic programs
What is C++
case-sensitive(Hello" and "hello" would be considered different)
Standard Template Library (STL) many functions are available that help in quickly
writing code.
like sets, maps, hash tables, etc.
Procedures are sometimes called "void functions, indicating that they do not return
any value. Instead, they carry out a sequence of actions or operations.
History
Performance: C++ is known for its high performance and efficiency. This includes
real-time systems, game development, scientific computing, and high-frequency
trading platforms.
Game Development: C++ is a popular choice for game development due to its
performance, control over hardware, and the availability of game development
libraries and engines like Unreal Engine, which is primarily written in C++.
The uses of C++ can be found in almost all applications today. Here are some
interesting areas where C++ is popularly used.
1. Operating Systems
Mac OS X has large amounts written in C++.
Microsoft like Windows, Microsoft Office, IDE Visual Studio, and Internet
Explorer are also written in C++.
2. Games
3. Web Browsers
Mozilla Firefox totally build using CPP, Also software like Chrome and google file.
2) Abstract Data types: complex data types called Abstract Data Types (ADT) can
be created using classes.
6) Rich Library: It provides inbuilt functions that make the development fast
<iostream>
<cmath>
<cstdlib>
<fstream>
16) Errors are easily detected: exception handling to support error handling in
your program.
Many compilers and interpreters for other languages such as FORTRAN, PERL,
Python, PASCAL, BASIC, LISP, etc., have been written in C++.
C C++
If we don’t want to use this line of code, we can use the things in this namespace like
this. std::cout, std::endl.
#include<iostream> #include<iostream>
Int main {
{ Std::cout<<”HW”;
cout<<”HW”; return 0;
return 0; }
}
C++ Data Types
Data type specifies which type of data a variable or object can hold.
Variables are containers for storing data values.
A variable is a name of memory location. It is used to store data. Its value can be
changed and it can be reused many times.
Identifiers is a name given to a programming construct such as a variable, function,
class,arrays, or other user-defined data types created by the programmer
cout :
cin :
binary numbers
Characters
4 Swap by Arithmetic
5 Using Bitwise Operator
In C++ std::array is a container that encapsulates fixed size arrays. In C++, array
index starts from 0. We can store only fixed set of elements in C++ array.
They can be used to store a collection of any type of primitive data type, including int,
float, double, char, etc. An array in C/C++ can also store derived data types like
structures, pointers, and other data types, which is an addition. The array
representation in a picture is provided below.
C++ Passing Array to Function
Passing Array to Function: Print minimum number
Passing Array to Function: Print maximum number
C++ Multidimensional Arrays
two dimensional or three dimensional. The data is stored in tabular form (row ∗
The multidimensional array is also known as rectangular arrays in C++. It can be
The max(x,y) function can be used to find the highest value of x and y:
#include<cmath>
max(x,y) function can be used to find the highest value of x and y
min(x,y) function can be used to find the lowest value of x and y
pow(x,y) It computes x raised to the power y.
sqrt(x) It computes the square root of x.
cbrt(x) cube root of x
round(2.6) Round up value to nearest.
round(2.0) 2
round(2.1) 2
round(2.2) 2
round(2.3) 2
round(2.4) 2
round(2.5) 3
round(2.6) 3
round(2.7) 3
round(2.8) 3
round(2.9) 3
ceil(2.2) 3
ceil(2.3) 3
ceil(2.4) 3
ceil(2.5) 3
ceil(2.6) 3
ceil(2.7) 3
ceil(2.8) 3
ceil(2.9) 3
OP-4 4 8 1
OP-4
OP-8
OP-12
OP-20
The fun() would return the size of the integer pointer, i.e., int*, and the size of the
int* is 8 bytes in the 64-bit operating system.
O/P 8 bytes
Structure Binding
Structured binding is one of the newest features of C++17 that binds the specified
names to subobjects or elements of initializer.
This feature simplifies code and improves readability when working with complex
data structures, such as tuples, pairs, or user-defined structures
The main purpose is to make the code clean and easy to understand.