Home Learning About Contact

The C++

general-purpose object-oriented programming language developed by Bjarne Stroustrup of Bell Labs in 1979. C++ was originally called 'C with classes,' and was built as an extension of the C language. Its name reflects its origins; C++ literally means 'increment C by 1

What is the basic structure of a C++ program?
c++ beginner Edpresso Team Structure of a C++ program A C++ program is structured in a specific and particular manner. In C++, a program is divided into the following three sections: Standard Libraries Section Main Function Section Function Body Section

For example, lets look at the implementation of the Hello World program: hello world

namespace std; #include is a specific preprocessor command that effectively copies and pastes the entire text of the file, specified between the angle brackets, into the source code. The file , which is a standard file that should come with the C++ compiler, is short for input-output streams. This command contains code for displaying and getting an input from the user. namespace is a prefix that is applied to all the names in a certain set. iostream file defines two names used in this program - cout and endl. This code is saying: Use the cout and endl tools from the std toolbox. Main function section 1 int main() {} The starting point of all C++ programs is the main function. This function is called by the operating system when your program is executed by the computer. { signifies the start of a block of code, ​and } signifies the end. Function body section 1 cout << "Hello World" << endl; 2 return 0; The name cout is short for character output and displays whatever is between the << brackets. Symbols such as << can also behave like functions and are used with the keyword cout. The return keyword tells the program to return a value to the function int main After the return statement, execution control returns to the operating system component that launched this program.

Uses of C++
Games  

Close to the hardware, can easily manipulate resources, provide procedural programming over CPU intensive functions and is fast. It is also able to override the complexities of 3D games and provides multilayer networking. All these benefits of C++ make it a primary choice to develop the gaming systems as well as game development suites. close to the hardware, can easily manipulate resources, provide procedural programming over CPU intensive functions and is fast. It is also able to override the complexities of 3D games and provides multilayer networking. All these benefits of C++ make it a primary choice to develop the gaming systems as well as game development suites.

Database  

C++ is also used in writing database management software. The two most popular databases MySQL and Postgres are written in C++. MYSQL Serve MySQL, one of the most popular database software that is used widely in many real-world applications is written in C++. This is the world’s most popular open-source database. This database is written in C++ and is used by most of the organizations. . .


Data types
Data types Keyword Size in bytes
Integer(int) int 2 or 4
Character char 1
Boolean(bool) bool(true or false) 1
String string 1
Floating point float 4
Double Floating Point double 8
Wide Character wchar_t 2
Void void empty

1. The int keyword is used to indicate integers. Its size is usually 4 bytes. Meaning, it can store values from -2147483648 to 2147483647
For example :
int salary =1000;

2. Keyword char is used for characters. Its size is 1 byte. Characters in C++ are enclosed inside single quotes ' '.
For example :
char test = 'h' ;

3. The bool data type has one of two possible values: true or false. Booleans are used in conditional statements and loops
For example :
bool cond = false;

4.5 float and double are used to store floating-point numbers (decimals and exponentials). The size of float is 4 bytes and the size of double is 8 bytes. Hence, double has two times the precision of float. To learn more, visit C++ float and double.
For example :
float area = 80.74; double volume = 100.687874;

6. Strings are used for storing text. A string variable contains a collection of characters surrounded by double quotes
For example :
string saysomething = "Hello";

7. Wide character wchar_t is similar to the char data type, except its size is 2 bytes instead of 1. It is used to represent characters that require more memory to represent them than a single char.
For example :
wchar_t test = L'ם'

8.The void keyword indicates an absence of data. It means "nothing" or "no value".

C++ Type Modifiers

We can further modify some of the fundamental data types by using type modifiers.


Data Type Size(In byte) Range
short int 2 -32,768 to 32,767
unsigned int 4 0 to 4294967295
signed int 4 -2147483648 to 2147483647
unsigned short int 2 0 to 65,535
signed short int 2 -32768 to 32767
long int 8 -2,147,483,648 to 2,147,483,647
signed long int 8 same as long int
unsigned long int 8 0 to 4,294,967,295
long long int 8 -(2^63) to (2^63)-1
unsigned long long int 8 0 to 18,446,744,073,709,551,615
unsigned char 1 0 to 255
signed char 1 -127 to 127

The size of variables might be different from those shown in the above table, depending on the compiler and the computer you are using.

next page