Found 9150 Articles for Object Oriented 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

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

Write a C++ Program without Semicolons?

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

429 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

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

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

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

713 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

What is the difference between cin and cout streams in c++?

Akansha Kumari
Updated on 05-May-2025 17:05:21

17K+ Views

cin is an object of the input stream and is used to take input from input streams like files, console, etc. cout is an object of the output stream that is used to show output. Basically, cin is an input statement while cout is an output statement.They also use different operators. cin uses the insertion operator( >> ) while cout uses the extraction operator( >), which helps to extract the input from the cin and stores it in a variable. It automatically skips the whitespaces (spaces, tabs, newlines) until a special method like getline() is used. Syntax Here is the ... Read More

Comparison between endl and in C++

Arjun Thakur
Updated on 30-Jul-2019 22:30:21

218 Views

"" Outputs a newline (in the appropriate platform-specific representation, so it generates a "\r" on Windows), but std::endl does the same and flushes the stream. Usually, you don't need to flush the stream immediately and it'll just cost you performance, so, for the most part, there's no reason to use std::endl.When you want to flush the stream manually -- e.g. because you expect your output to be made visible to the user in a timely fashion -- you should use std::endl instead of writing '' to the stream (whether as an isolated character or part of a string). Read More

What is the difference between cerr and cout streams in c++?

Akansha Kumari
Updated on 02-May-2025 18:48:58

4K+ Views

cout is an object of the stdout stream, while cerr is an object of the stderr stream.stdout and stderr are different streams, even though they both refer to console output by default. Redirecting (piping) one of them (e.g., program.exe >out.txt) would not affect the other. These are both provided by the library in C++. In this article, we will learn the difference between these two output streams in more detail. Character Output Stream (cout) The character output stream is used to display the data or information to the console (standard output device, basically the screen), like printing messages, results, ... Read More

Advertisements