C++ Code
Equality testing sign
==
What is a place holder
A variable x = bacon
Integer
A whole number a number that is not a fraction
What are Statements
All functions in between the { }
What does a while loop do
All it does is run a loop over and over again unless the test you specify is false.
IDE
Allows to write the code and run it
cout << "Boy I love bacon \n";
Another way of moving to a new line without the endl; Must be inside Quotation marks.
Coersion
Auto conversion of an operand to another data type
cout << "Boy\n I\n love\n bacon \n";
Each word printed on a new line.
endl;
End line, or go to the next line. If you do not put it in and just end with a semicolon then it joins both lines even though it was written on two separate lines.
/* erewrewr rewrewrewrwerewrwerewrewr fdsfdsfsfds tretretretretertretre gfdgfdgfdgfdgfdgdfg tretertertretretretret*/
Entire block is a comment.
return0;
It just tells you that the program ran fine from int main till the end. If there were errors it would not run. It means main ran fine.
Declaring the variable
It when you declare the value of int a; but assign a value to it later on a = 54;
int main()
Must start out with this it tells C++ where to start reading from. int tells C++ what type of data to work with, if you're doing calc etc it will auto return integers, not floats.
Blank Lines
No effect just make code easier to read.
What do Tabed spaces do
No effects just made code neater
Whole Number
Number without fraction an integer.
What is cout
Output stream object. It's used to type object on the computer screen. Must accompany <<
( )
Parenthesis
setw
Pgm 3-15 Set width for data to be displayed. must load # include <iomanip> must be entered after each display you want min (6)
;
Semi colon
what is std;
Standard library we use only standard built in functions in C++
What are these called >>
Stream extraction operator.
How to use a remainder of a number
Use modulus %
Double
a float outranks an in a double outranks a float long double outranks a double and can hold the biggest number
How to deal with exponents in C++
area = 4² write as area = pow(4.0 , 2); but you must use: # include <cmath>
const
called constant variable like const double TAX_RATE const int NUM_STATES when you specify the contents not to be changed during a program.
Promotion
converts to a higher type
Demotion
converts to a lower type.
What is a data type for integers
int
char letter;
letter = "A"; When letter is printed it just prints A. char just holds 1 character.
2nd line of C++
using namespace std;
1st line of C++
# include <iostream>
What is used for comments in C++
// forward slash
What does cout and cin require to work
Both require the <iostream> file to loaded.
{ }
Brace
{ }
Braces
[ ]
Brackets
:
Colon
Compiler
Converts code for a computer to understand. Turns code to 1010101010
"
Double Quotes ' Single Quote
Define ; semi colon in C++
Each function in C++ must end with it or it won't know where to end.
What are these called <<
The stream insertion operator, it takes everything after it and prints it out on the screen.
set precision
This is define how many numbers you want shown after the decimal point.
Set Precision
This is used to set the precision of a floating point or double to a certain number of significant digits. Must load #include <iomanip> // Header file needed to use set precision. cout<<fixed<<setprecision(0)<< if fixed is not used answer will appear in scientific notation.
cout << "Boy I love bacon \n\n";
This will leave 1 blank line.