@@ -153,7 +153,7 @@ are actually ``1`` and ``0`` respectively. Hence, we see this in output as well.
153153 #include <iostream>
154154 using namespace std;
155155
156- // function that demonstrates logical operators
156+ // function that demonstrates logical operators
157157 int main() {
158158 cout << true << endl;
159159 cout << false << endl;
@@ -166,7 +166,7 @@ are actually ``1`` and ``0`` respectively. Hence, we see this in output as well.
166166
167167 .. activecode :: logical_1py
168168 :caption: Logical Operators Python
169-
169+
170170 # Function that demonstrates logical operators.
171171 def main():
172172 print(True)
@@ -211,8 +211,8 @@ and logical operators with examples shown in the session that follows.
211211
212212 #include <iostream>
213213 using namespace std;
214-
215- // function that demonstrates relational operators.
214+
215+ // function that demonstrates relational operators.
216216 int main(){
217217
218218 cout << (5 == 10) << endl;
@@ -226,7 +226,7 @@ and logical operators with examples shown in the session that follows.
226226
227227 .. activecode :: logicalpy
228228 :caption: Basic Relational and Logical Operators Python
229-
229+
230230 # Function that demonstrates relational operators.
231231 def main():
232232
@@ -339,8 +339,8 @@ Consider the following code.
339339 #include <string>
340340 using namespace std;
341341
342- // Demonstrates how chars and strings can not be
343- // directly compared.
342+ // Demonstrates how chars and strings can not be
343+ // directly compared.
344344 int main(){
345345
346346 string strvar = "b";
@@ -376,7 +376,7 @@ Pointers
376376~~~~~~~~
377377
378378A C++ **pointer ** is a variable that stores a memory address and can be used to indirectly
379- access data stored at that memory location.
379+ access data stored at that memory location.
380380
381381We know that variables in a computer program are used to label data with a
382382descriptive identifier so that the data can be accessed and used by that
@@ -428,7 +428,7 @@ In C++ the results of running this code will look like the diagram below:
428428In each case, when we want to output the value to the console, we use the variable name
429429to do so.
430430
431- But, we can also identify the memory location of the variable by its address.
431+ But, we can also identify the memory location of the variable by its address.
432432In both Python and C++, this address
433433may change each time the program is run. In C++, the address will always look
434434odd because it will be the actual memory address written in a hexadecimal code
@@ -453,7 +453,7 @@ while in C++ we use the *address-of operator*, ``&``.
453453
454454
455455 // outputs the value of a variable
456- // as well as the memory address in C++.
456+ // as well as the memory address in C++.
457457 int main(){
458458 int varN = 101;
459459 cout << varN << endl;
@@ -493,7 +493,7 @@ Pointer Syntax
493493^^^^^^^^^^^^^^
494494
495495When declaring a pointer in C++ that will "point" to the memory address of some
496- data type,
496+ data type,
497497you will use the same rules of declaring variables and data types.
498498The key difference is that there must be an asterisk (*) between the data type and the
499499identifier.
@@ -523,25 +523,25 @@ Now that we know how to declare pointers, how do we give them the address of
523523where the value is going to be stored? One way to do this is to have a pointer
524524refer to another variable by using the address-of operator, which is denoted by the
525525ampersand symbol, ``& ``. The address-of operator ``& `` does exactly what it indicates,
526+ variableType varN; // a variable to hold the value
526527namely it returns the address.
527528
528529The syntax is shown below, where varN stores the value, and ptrN stores
529530the address of where varN is located:
530531
531532::
532533
533- variableType varN; // a variable to hold the value
534534 variableType *ptrN = &varN; // a variable pointing to the address of varN
535535
536536Keep in mind that when declaring a C++ pointer, the pointer needs to
537537reference the same type as the variable or constant to which it points.
538538
539- Expanding on the example above where varN has the value of 100 .
539+ Expanding on the example above where varN has the value of 9 .
540540
541541::
542542
543543 //variable declaration for a single integer value
544- int varN = 100 ;
544+ int varN = 9 ;
545545 int *ptrN;
546546 ptrN = &varN;
547547
@@ -558,14 +558,14 @@ The results of running this C++ code will look like the diagram below.
558558Accessing Values from Pointers
559559^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
560560
561- Once you have a C++ pointer, you use the asterisk before the pointer variable,
561+ Once you have a C++ pointer, you use the asterisk before the pointer variable,
562562to *dereference * the pointer, which means go to the location pointed at by the 3.
563563
564564::
565565
566566 In other words, varN and *ptrN (note the asterisk in front!) reference the same
567567 value in the code above.
568-
568+
569569
570570Let's extend the example above to output the value of a variable and its address
571571in memory:
@@ -577,23 +577,23 @@ in memory:
577577
578578 #include <iostream>
579579 using namespace std;
580-
581- // demonstrates what happens when you dereference a pointer
580+
581+ // demonstrates what happens when you dereference a pointer
582582 int main( ) {
583- int varN = 100 ;
583+ int varN = 9 ;
584584 int *ptrN = &varN; // ptrN points to varN address
585585
586586 cout << "varN value: " << varN << endl;
587587 cout << "varN location: " << ptrN << endl;
588588 cout << "dereference ptrN: " << *ptrN << endl;
589589
590-
590+
591591 return 0;
592592 }
593-
593+
594594
595595.. mchoice :: mc_pntrhlp
596- :answer_a: varPntr: 100
596+ :answer_a: varPntr: 9
597597 :answer_b: varPntr: 50
598598 :answer_c: varPntr: 150
599599 :answer_d: 0x7ffeb9ce053c
@@ -604,8 +604,8 @@ in memory:
604604 :feedback_c: No, the values do not add together!
605605 :feedback_d: We are dereferencing the pointer, so you would not get the address of varN. Try again!
606606 :feedback_e: One of the above is indeed correct.
607-
608- If the lines (varN = 50;) and (cout << \* ptrN << endl;) were inserted into line 7-8, what would it cout?
607+
608+ If the lines (varN = 50;) and (cout << \* ptrN << endl;) were inserted into line 7-8, what would it cout?
609609
610610Compiling and running the above code will have the program output the
611611value in varN,
0 commit comments