Tag c++ string

C++ Comments

C++ Comments Comments can be used to explain C++ code, and to make it more readable. It can also be used to prevent execution when testing alternative code. Comments can be singled-lined or multi-lined.

C++ New Lines

New Lines To insert a new line in your output, you can use the \n character: Example #include <iostream> using namespace std; int main() {   cout << “Hello World! \n”;   cout << “I am learning C++”;   return…

C++ Output Numbers

C++ Print Numbers You can also use cout() to print numbers. However, unlike text, we don’t put numbers inside double quotes: Example #include <iostream> using namespace std; int main() {   cout << 3;   return 0; } You can…

C++ Output

C++ Output (Print Text) The cout object, together with the << operator, is used to output values and print text. Just remember to surround the text with double quotes (“”):

C++ Statements

C++ Statements A computer program is a list of “instructions” to be “executed” by a computer. In a programming language, these programming instructions are called statements. The following statement “instructs” the compiler to print the text “Hello World” to the…

C++ Syntax

C++ Syntax Let’s break up the following code to understand it better: Example #include <iostream> using namespace std; int main() {   cout << “Hello World!”;   return 0; } Example explained Line 1: #include <iostream> is a header file…

C++ Getting Started

C++ Get Started To start using C++, you need two things: A text editor, like Notepad, to write C++ code A compiler, like GCC, to translate the C++ code into a language that the computer will understand There are many…