## C++ Math – Your Fav Topic

C++ Math Functions Examples #include <cmath> You can copy this code below. In most of these examples, we encourage users to copy the code below. // Math your fav topic #include <iostream> #include <cmath> using namespace std; int main(){ cout << "sqrt(144) = " << sqrt(144) << endl; cout << "round(2.65) = " << round(2.65) << endl; cout <<...

## C++ Array of Ints / Integers

#include <array>std::array<int,4> myGrades = {86,80,64,91}; Sample c++ Array of ints Code // std::array usage std::array<int,4> myGrades = {86,80,64,91}; #include <iostream> #include <array> using namespace std; int main(){ float sum = 0.0f; std::array<int,9> myGrades = {86,80,64,91,52,59,88,69,75}; for ( unsigned int i = 0; i < myGrades.size();i++){ std::cout <<...

## C++ Array of Strings

There are a few different ways of creating a c++ Arrays of Strings #include <array>using namespace std;std::array<string,4> family = {"brother","sister","father","mom"} // std::array usage std::array<string,3> family = {"Me","You","Them"} #include <iostream> #include <array> using namespace std; int main(){ std::array<string,6> classmates = {"George",...

## C++ Do While Syntax

Elements of a c++ do while loop do { statement(s); } while( condition ); #include <iostream> int main(){ int userCounter = 0,cnt=0; std::cout << "how many times should we loop ?\n"; std::cin >> userCounter; do { std::cout << "Counting to " << userCounter << " now in the loop for " << cnt + 1 << " times\n"; cnt++; }while( cnt < userCounter ); } So Line 13...

## C++ While loop example

As part of the flow control, we will write a c++ while loop example then examine its elements. #include <iostream> int main(){ int cnt = 0; bool isReady = true; while( isReady ){ std::cout << "Are we really in a loop\n"; ++cnt; if ( cnt > 5 ) isReady = false; } } Line 9. Does the c++ while loop example really loop only 5 times? C++ Loop Code Example So, did everything run ok? I see the...

## C++ Flow Control if else switch case syntax – steal our code

There are a number of flow control syntax constructs in C++. They are basically the same as those in C, so if you are a C programmer you can skip this section. The c++ flow control constructs involve variations of : if, if else if syntax, while(isTrue) ..., do ... while(isTrue) and my favorite ...c++ switch case syntax ...with variations of continue, break and default c++ Flow Control Code...
Top