Found 7197 Articles for C++

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

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

179 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

426 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

418 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

C++ Relational and Equality Operators

Srinivas Gorla
Updated on 11-Feb-2020 05:40:45

2K+ Views

In C Programming, the values hold on in 2 variables will be compared exploitation following operators and relation between them will be determined. These operators are called relational operators. Various C++ relational operators available are-OperatorsDescription>Greater than>=Greater than or equal to

Semicolons in C++

Akansha Kumari
Updated on 30-Apr-2025 20:26:37

1K+ Views

A semicolon in C++ is used to terminate or end the statement; it tells the compiler that this particular instruction is completed.According to the ISO C++ specifications, the lexical representation of C++ programs (breaking down code into small parts) is called tokens. Some of these tokens are punctuators, which are special symbols used to structure your code. The semicolon is one of these punctuators. Example Here is the following basic example code showcasing the working of a semicolon in C++. #include using namespace std; int main() { int x = 5; // End of declaration statement x = 10; // End of assignment statement cout

Conditional ternary operator ( ?: ) in C++

Abhinanda Shri
Updated on 11-Feb-2020 05:30:35

641 Views

The conditional operator (? :) is a ternary operator (it takes three operands). The conditional operator works as follows −The first operand is implicitly converted to bool. It is evaluated and all side effects are completed before continuing.If the first operand evaluates to true (1), the second operand is evaluated.If the first operand evaluates to false (0), the third operand is evaluated.The result of the conditional operator is the result of whichever operand is evaluated — the second or the third. Only one of the last two operands is evaluated in a conditional expression. The evaluation of the conditional operator ... Read More

What are C++ Manipulators (endl, setw, setprecision, setf)?

Akansha Kumari
Updated on 04-Jun-2025 13:33:54

4K+ Views

Manipulators in C++ are like helper functions that are designed to format and modify the input and output streams of your code. This is done by using the insertion () operators, and are defined in and header files. There are various types of manipulators that exist in C++, but in this article, we will be discussing the four main types, which are commonly used. endl setw setprecision setf C++ endl Manipulator The endl manipulator has the same functionality as ''(newline ... Read More

Basics of C++ Programming Language?

Kumar Varma
Updated on 11-Feb-2020 05:19:52

711 Views

C++ is a programming language developed by Bjarne Stroustrup in 1979 at Bell Labs. C++ is regarded as a middle-level language, as it comprises a combination of both high-level and low-level language features. It is a superset of C, and that virtually any legal C program is a legal C++ program. C++ runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX. It is a language that is −Statically typed − A programming language is said to use static typing when type checking is performed during compile-time as opposed to run-time.Compiled − A compiled ... Read More

Compound Assignment Operators in C++

Govinda Sai
Updated on 11-Feb-2020 05:10:31

4K+ Views

The compound assignment operators are specified in the form e1 op= e2, where e1 is a modifiable l-value not of const type and e2 is one of the following −An arithmetic typeA pointer, if op is + or –The e1 op= e2 form behaves as e1 = e1 op e2, but e1 is evaluated only once.The following are the compound assignment operators in C++ −OperatorsDescription*=Multiply the value of the first operand by the value of the second operand; store the result in the object specified by the first operand./=Divide the value of the first operand by the value of the ... Read More

Advertisements