Found 7197 Articles for C++

Print Hello World without semicolon in C++

Alshifa Hasnain
Updated on 07-Apr-2025 12:11:49

2K+ Views

In this article, we will learn to print Hello World without a semicolon in C++. The semicolon (;) is used to terminate statements. The above can be achieved by using control structures like loops, conditionals, or function calls. Different Approaches There are multiple ways to write a C++ program without semicolons − Using if Statements Using a while Loop Using Switch Statement Note: Doing this is a very bad practice and should never be used in real code. This is presented just as informational content. ... Read More

Putting semicolons after while and if statements in C++

Akansha Kumari
Updated on 23-Apr-2025 19:19:08

3K+ Views

In C++, a semicolon(;) indicates the end of a statement in code, or we can say it terminates the statement. When you use a semicolon just after an if or while statement, it creates an empty statement, which executes nothing. Semicolon with If Statement In C++, the if statement is a conditional statement that runs only if the condition is true, where {} braces are used to write the condition inside them. But if you use a semicolon just after the if statement, it will still check the condition, but it controls just an empty operation; therefore, nothing will happen ... Read More

Unary operators in C++

Rama Giri
Updated on 11-Feb-2020 06:53:36

343 Views

Unary operator are operators that act upon a single operand to produce a new value. The unary operators are as follows −Indirection operator (*) - It operates on a pointer variable, and returns an l-value equivalent to the value at the pointer address. This is called "dereferencing" the pointer.Address-of operator (&) - The unary address-of operator (&) takes the address of its operand. The operand of the address-of operator can be either a function designator or an l-value that designates an object that is not a bit field and is not declared with the register storage-class specifier.Unary plus operator (+) - ... Read More

Reserved keywords in C++?

Arjun Thakur
Updated on 19-Jun-2020 05:31:50

10K+ Views

A reserved word is a word that cannot be used as an identifier, such as the name of a variable, function, or label – it is "reserved from use". This is a syntactic definition, and a reserved word may have no meaning.There are a total of 95 reserved words in C++. The reserved words of C++ may be conveniently placed into several groups. In the first group, we put those that were also present in the C programming language and have been carried over into C++. There are 32 of these. There are another 30 reserved words that were not in ... Read More

Trigraphs in C++

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

322 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

538 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

Advertisements