- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 7346 Articles for C++
2K+ Views
In the prefix version (i.e., ++i), the value of i is incremented, and the value of the expression is the new value of i. So basically it first increments then assigns a value to the expression. In the postfix version (i.e., i++), the value of i is incremented, however, the {value|the worth} of the expression is that the original value of i. So basically it first assigns a value to expression and then increments the variable.Let's look at some code to get a better understanding −Example#include using namespace std; int main() { int x = 3, y, z; ... Read More
697 Views
An enumerated type declares an optional type name and a set of zero or more identifiers that can be used as values of the type. Each enumerator is a constant whose type is the enumeration. For example, if you are creating an application that has a fixed number of types for some variable. For example, let's say gender, it can be of three types male, female and others. You can define and use an enum like −#include using namespace std; enum Gender {MALE, FEMALE, OTHERS}; int main() { Gender gen = Gender.FEMALE; return 0; }By default, the value ... Read More
4K+ Views
Postfix operators are unary operators that work on a single variable which can be used to increment or decrement a value by 1(unless overloaded). There are 2 postfix operators in C++, ++ and --.In the postfix notation (i.e., i++), the value of i is incremented, but the value of the expression is the original value of i. So basically it first assigns a value to expression and then increments the variable. For example, Example#include using namespace std; int main() { int j = 0, i = 10; // If we assign j to be i++, j ... Read More
188 Views
The multiplicative operators are −Multiplication (*)Division (/)Modulus or “remainder from division” (%)These binary operators have left-to-right associativity. The multiplicative operators take operands of arithmetic sorts. The modulus operator (%) contains a stricter requirement in this its operands should be of integral type.The multiplication operator yields the result of multiplying the first operand by the second.The division operator yields the result of dividing the first operand by the second.The modulus operator yields the remainder given by the subsequent expression, wherever e1 is that the 1st operand and e2 is that the second: e1 – (e1 / e2) * e2, where both ... Read More
338 Views
The typedef keyword in C++ can be used to give a type a new name. For example, you can give a new name of BYTE to unsigned characters −typedef unsigned char BYTE;After this type definition, the identifier BYTE can be used as an abbreviation for the type unsigned char, for example −BYTE b1, b2;This will declare 2 variables b1 and b2 of type unsigned char. Typedefs are really useful when you have huge names due to namespaces, class names, etc. For example, if you want a variable of type std::vector::iterator multiple times throughout your program. You can just rename it ... Read More
196 Views
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. All characters available inside any comment are ignored by C++ compiler.Single line commentsTo create a single line comment, we use the // notation. Wherever you want to start the comment, start it with //. For example,// This is a comment cout
126 Views
The bitwise OR operator (|) compares each bit of first operand to the corresponding bit of second operand. If either bit is 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. Both operands to the bitwise inclusive OR operator must be of integral types. For example,Example#include using namespace std; int main() { unsigned short a = 0x5555; // pattern 0101 ... unsigned short b = 0xAAAA; // pattern 1010 ... cout
127 Views
The bitwise AND operator (&) compares each bit of first operand to the corresponding bit of second operand. If both bits are 1, the corresponding result bit is set to 1. Otherwise, the corresponding result bit is set to 0. Both operands to the bitwise inclusive AND operator must be of integral types. For example,Example#include using namespace std; int main() { unsigned short a = 0x5555; // pattern 0101 ... unsigned short b = 0xAAAA; // pattern 1010 ... cout
2K+ Views
A fundamental or primitive type is a data type where the values that it can represent have a very simple nature (a number, a character or a truth-value); the primitive types are the most basic building blocks for any programming language and are the base for more complex data types.C++ has the following primitive data types −S.NoTypeDescription1boolStores either value true or false.2charTypically a single octet (one byte). This is an integer type.3intThe most natural size of an integer for the machine.4floatA single-precision floating point value.5doubleA double-precision floating point value.6voidRepresents the absence of type.Read More