Found 9321 Articles for Object Oriented Programming

C++ Keywords

Alankritha Ammu
Updated on 30-Jul-2019 22:30:21

6K+ Views

Keywords are those words whose meaning is already defined by Compiler. These keywords cannot be used as an identifier. Note that keywords are the collection of reserved words and predefined identifiers. Predefined identifiers are identifiers that are defined by the compiler but can be changed in meaning by the user. For example, you could declare a variable called main inside your main function, initialize it, and then print out its value (but ONLY do that to verify that you can!). On the other hand, you could not do this with a variable named else. The difference is that else is a ... 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

302 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

839 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++

Paul Richard
Updated on 19-Jun-2020 05:27:03

810 Views

According to the ISO C++ specifications, The lexical representation of C++ programs includes a number of preprocessing tokens which are used in the syntax of the preprocessor or are converted into tokens for operators and punctuators. The semicolon is a punctuator in C++.A semicolon character is at the end of the following parts of a C++ grammar (not necessarily a complete list) −an expression-statementa do/while iteration-statementthe various jump-statementsthe simple-declarationThese are all part of the C++ grammar. You can read more about these statements in the ISO C++ specification.

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

Rama Giri
Updated on 11-Feb-2020 05:28:21

3K+ Views

Stream Manipulators are functions specifically designed to be used in conjunction with the insertion () operators on stream objects, for example −std::cout

Basics of C++ Programming Language?

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

484 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++?

Akshaya Akki
Updated on 11-Feb-2020 05:03:02

15K+ 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(

Comparison between endl and in C++

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

137 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++?

Akshaya Akki
Updated on 30-Jul-2019 22:30:21

3K+ 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.Generally, stdout ought to be used for actual program output, whereas all information and error messages should be printed to stderr, in order that if the user redirects output to a file, information messages are still printed on the screen and not to the output file.

Advertisements