C++, A Foreign Language
Wednesday, May 16, 2018
|| and && Operators
The "||" and "&&" operators, and/or respectively, are generally used for If statements, and either evaluate to the Boolean values True or False. The way it works is simple, the operator is put between two other "==" statements, and for the AND operator, if (1==1&&2==2) the statement will evaluate to true. If only one statement is true, then the whole statement is false. The OR operator works so that if (water == water || 2 == 1), even though 2 is not equal to 1 half of the statement is true so the entire statement is true.
Thursday, May 10, 2018
If statements
In most programming languages there are statements called "If-statements" which, as shown in the above diagram, check to see if a statement comes out to be true or false. If the statement, such as "if (1==1){" will execute the code to the next brace. In C++, you have to remember that the "=" operator is the assignment operator which assigns the value of the object on the left to the variable on the right.
Friday, April 27, 2018
Learning Pre-operations
In C++, the lines of code that start with a pound sign (#) are dedicated commands for the pre-processor, which is basically the part of the compiler that dictates what the compiler is going to need to know. In this screenshot, the user has added the command #include <iostream>, which basically tells the compiler to begin running. The user has also defined variables A and B which are set to 0. And lastly, using namespace std; tells the compiler that each time it sees a command such as cout, (nromally std::cout), it tells it that there is the std:: operator in front of it.
Tuesday, April 24, 2018
Finding a Compiler
In C++, you require a "compiler" to run and test your programs. After a while of searching, I found a decent, online compiler. It does everything I need it to do without having to download a program to run my programs. I am using cpp.sh.
Thursday, April 19, 2018
C++
Subscribe to:
Posts (Atom)