Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
C++ Articles - Page 709 of 719
7K+ Views
In C++, bitwise operators are used to perform operations on binary numbers. Since computers store all data in the form of binary (0s and 1s), therefore, every value, like decimal numbers, characters, and booleans, is internally represented in binary. for example: 5 = 00000101 and 3 = 00000011 To learn more about how to convert these decimal values to binary, you can visit this page: Decimal to Binary Conversion. Shift Operators in C++ The shift operator is one of the types of bitwise operators, which are used to move bits of a number left or right. There are two types of ... Read More
321 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
582 Views
In C++, typedef is a keyword that is used to create a new name for an existing data type. This helps the users to modify the code according to their preference, making it more readable, friendly, and manageable. Syntax Here is the following basic syntax of typedef in C++; typedef existing_type new_name; Here, existing_type is the original data type given in the C++ standard (e.g., int, float, double, etc.)new_name is the new name assigned to that type. Example Here is the following simple example showcasing the use of typedef in C++: #include using namespace std; // Defining ... 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
858 Views
Bitwise operators are the operators that are used to perform operations on bits of a binary representation of a number.Bitwise OR (|) Operator OR Operator (|) is one of the types of bitwise operators, which compares each bit of the first operand to the corresponding bit of the second operand and returns 1 if at least one of the bits is 1; else 0 if both bits are 0. You can think of it as similar to addition in decimal, like 0 + 0 = 0, and all other combinations result in 1. But this ... Read More
725 Views
The Bitwise AND (&) Operator is one of the types of bitwise operators, which perform operations on bits of a binary representation. The Bitwise AND (&) compares each bit of the first operand to the corresponding bit of the second operand and returns 1 if both bits are 1, else returns 0 if either or both bits are 0.You can think of it as similar to multiplication in decimal, like 1 * 1 = 1, and all other combinations result in 0. But ensure that both operands are of integral data types (as it works with binary representations) like int, ... Read More
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
499 Views
The XOR operator(^), also known as "exclusive OR", is one of the types of bitwise operators, which compares each bit of the first operand to the corresponding bit of the second operand and returns 1 if both bits are different, else returns 0 if both are the same. This only works with integral data types like int, char, short, long, and unsigned int, etc, and cannot be directly used with float, double, string, and class/struct objects, etc. Syntax Here is the following syntax of Bitwise XOR. result = operand1 ^ operand2; Where operand1 and operand2 are the integral types (like ... Read More
377 Views
The single operators operate on one quantity and following are the samples of single operators − - The increment ( ) and decrement (--) operators. The compiler distinguishes between the different meanings of an operator by examining the types of its operands.The unary operators operate on a single operand and following are the examples of Unary operators −The increment (++) and decrement (--) operators.The unary minus (-) operator.The logical not (!) operator.The unary operators operate on the object for which they were called and normally, this operator appears on the left side of the object, as in !obj, -obj, and ... Read More
12K+ Views
Consider a situation, when we have two persons with the same name, Piyush, in the same class. Whenever we need to differentiate them definitely we would have to use some additional information along with their name, like either the area, if they live in a different area or their mother’s or father’s name, etc.The same situation can arise in your C++ applications. For example, you might be writing some code that has a function called xyz() and there is another library available which is also having same function xyz(). Now the compiler has no way of knowing which version of ... Read More