Found 33676 Articles for Programming

Trigraphs in C++

Akansha Kumari
Updated on 22-Apr-2025 18:50:06

325 Views

Trigraphs in C++ are special three-character sequences that represent a certain single character, which may not be available on some keyboards or systems. Previously, the ISO-646 character set did not have all the characters of the C syntax; therefore, some systems with their keyboard and display faced problems while dealing with those few characters.So the trigraphs have been introduced, which start with two question marks (??) and are further followed by a third character, which the compiler considers as a particular equivalent single-character. Trigraphs Table in C++ There are a total of nine trigraphs available in C++; here is the ... Read More

C++ Operators with Precedence and Associativity

Akansha Kumari
Updated on 29-May-2025 15:41:53

4K+ Views

In C++, operator precedence and associativity both work together to define the order of evaluation in an expression. Order precedence determines which operators need to be evaluated first according to precedence, whereas associativity defines the direction of operators to be evaluated of the same precedence. Operator precedence Operator precedence refers to the order of operations to be performed in expressions when multiple operators are present; here, operators with higher precedence (priority) are calculated first. For example: int x = 5 + 17 * 5; Here, according to operator precedence, multiplication has higher precedence than addition, therefore, it will first get ... Read More

Why does C++ need the scope resolution operator?

Nitya Raut
Updated on 11-Feb-2020 06:44:46

654 Views

The :: (scope resolution) operator is used to get hidden names due to variable scopes so that you can still use them. The scope resolution operator can be used as both unary and binary.You can use the unary scope operator if a namespace scope or global scope name is hidden by an explicit declaration of the same name in a block or class. For example, if you have a global variable of name my_var and a local variable of name my_var, to access global my_var, you'll need to use the scope resolution operator. For example, Example#include   using namespace ... Read More

What is the use of scope resolution operator in C++?

Jennifer Nicholas
Updated on 11-Feb-2020 06:43:03

544 Views

The :: (scope resolution) operator is used to get hidden names due to variable scopes so that you can still use them. The scope resolution operator can be used as both unary and binaryYou can use the single scope operator if a namespace scope or global scope name is hidden by a certain declaration of a similar name during a block or class. For example, if you have a global variable of name my_var and a local variable of name my_var, to access global my_var, you'll need to use the scope resolution operator. For example, Example#include   using namespace ... Read More

Equality Operators: == and != in C++

Vrundesha Joshi
Updated on 11-Feb-2020 05:58:08

844 Views

The equality operators in C++ are is equal to(==) and is not equal to(!=). They do the task as they are named. The binary equality operators compare their operands for strict equality or inequality. The equality operators, equal to (==) and not equal to (!=), have lower precedence than the relational operators, but they behave similarly. The result type for these operators is bool.The equal-to operator (==) returns true (1) if both operands have the same value; otherwise, it returns false (0). The not-equal-to operator (!=) returns true if the operands do not have the same value; otherwise, it returns ... Read More

When is a semicolon after } mandated in C++ Program?

George John
Updated on 30-Jul-2019 22:30:21

2K+ Views

A semicolon after a close brace is mandatory if this is the end of a declaration. In case of braces, they have used in declarations of class, enum, struct, and initialization syntax. At the end of each of these statements, we need to put a semicolon. For example, class X {}; // same declaration for struct as well enum Y {}; int z[] = {1, 2}; A semicolon by itself is an empty statement, and you'll be able to add additional ones anywhere a statement is legal. Therefore it might be legal to place a ... Read More

Why is sizeof() implemented as an operator in C++?

Nancy Den
Updated on 11-Feb-2020 05:56:32

181 Views

sizeof is not a real operator in C++. It is merely special syntax that inserts a continuing equal to the size of the argument. sizeof doesn’t want or have any runtime support. Sizeof cannot be overloaded because built-in operations, such as incrementing a pointer into an array implicitly depends on it.The C standard specifies that sizeof should be implemented as an operator. In most compilers, the value of sizeof is substituted by a constant equal to it at the compile time itself.example#include using namespace std; int main() {    cout

Write a C++ Program without Semicolons?

Anjana
Updated on 11-Feb-2020 05:55:11

432 Views

There are multiple ways to write a C++ program without semicolons. Note that doing this is very bad practice and should never be used in real code. This is presented just as informational content. The easiest way to write a C++ Program without Semicolons is using if statements. Almost all statements in C++ can be treated as expressions. So, if we place the statement inside an if statement with a blank pair of parentheses, we don’t have to end it with a semicolon anymore. For example, Example#include int main() {    if (int N = 1) {       ... Read More

Difference between Relational operator(==) and std::string::compare() in C++

Akansha Kumari
Updated on 30-Apr-2025 20:27:24

421 Views

In C++, both relational Operators (==) with std::string and std::string::compare() are used to compare two strings for equality, but there's a minor difference in both of these; == compares and returns the results in Boolean, whereas compare() checks lexicographically and returns the result in integers. In this article, we will see a more detailed comparison between these two methods and their uses in different scenarios. The == Operator The relational operator (==) is used to compare two values; it checks if the two given values are equal or not and returns the result in Boolean (True ... Read More

C++ Program Structure

Ayyan
Updated on 11-Feb-2020 05:49:42

1K+ Views

The best way to learn a programming language is by writing programs. Typically, the first program beginners write is a program called "Hello World", which simply prints "Hello World" to your computer screen. Although it is very simple, it contains all the fundamental components C++ programs have. Let's look at the code for this program −#include int main() {    std::cout

Advertisements