Data Types in C++
Data types are the type of data that a variable can store in a program.
1. Integer
- It is used to store integers.
- Integers take 4 bytes of memory.
Syntax
int var = 123;
2. Character
- It is used to store characters.
- It takes 1 bytes of memory.
Syntax
char var = 'a';
3. Floating Point
- It is used for storing single-precision floating-point numbers.
- It takes 4 bytes of memory.
Syntax
float num = 1.23;
4. Double
- It is used to store double-precision floating point numbers.
- It takes 8 bytes of memory.
Syntax
double num = 1.2345;
5. Boolean
- It is used to store logical values that can be either true or false.
Syntax
boolean b = false;
6. String
- A string is a collection of characters surrounded by double quotes. The string data type is used to store words or sentences.
- The string data type is part of the Standard Library and is defined in the <string> header file.
- We have to include <string> header file for using string class.
Syntax
string str = "w3wiki";
C++ Cheatsheet
This is a C++ programming cheat sheet. It is useful for beginners and intermediates looking to learn or revise the concepts of C++ programming. While learning a new language, it feels annoying to switch pages and find different websites for different concepts that are easily understandable. You can learn C++ concepts very easily using this cheat sheet.
C++ is a high-level programming language. It was developed in 1983 by Bjarne Stroustrup at Bell Labs. It is used for developing various applications.
Contact Us