Commit 90420e3b authored by GILLES Sebastien's avatar GILLES Sebastien
Browse files

Minor modifications following 2021-05-17 session (adding comments, removing...

Minor modifications following 2021-05-17 session (adding comments, removing std::cerr which was not properly introduced yet).
parent 0512d6dc
......@@ -109,7 +109,7 @@
"{\n",
" int a = 5;\n",
" int b(5);\n",
" int c = { 5 };\n",
" int c { 5 }; // From C++ 11 onward\n",
"}"
]
},
......@@ -1020,4 +1020,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
\ No newline at end of file
}
......@@ -685,7 +685,7 @@
"#include <vector> // we'll present this one more in detail later\n",
"\n",
"{\n",
" std::vector<int> v { 2, 3, 5, 7 };\n",
" std::vector<int> v { 2, 3, 5, 7 }; // and we're cheating here: C++ 03 syntax was here much worse as well...\n",
" \n",
" for (std::vector<int>::const_iterator it = v.cbegin(), \n",
" end = v.cend();\n",
......@@ -856,7 +856,7 @@
"\n",
"* `while` and (historical) `for` are completely interchangeable, as:\n",
" - A `while` loop is exactly like a `for ` loop with only the middle term.\n",
" - You can transform the loop into a while: putting the first term before the loop and the third one inside the loop to do so.\n",
" - You can transform a `for` loop into a `while` one: putting the first term before the loop and the third one inside the loop to do so.\n",
"* `do..while` behaves slightly differently, but you can always mimic the behaviour with another type of loop.\n",
"\n",
"Lots of programming language define these guys (at least `for` and `while`) so it's useful to know about them, but you can choose one and stick with it as well.\n"
......@@ -866,7 +866,6 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"© _CNRS 2016_ - _Inria 2018-2021_ \n",
"_This notebook is an adaptation of a lecture prepared by David Chamont (CNRS) under the terms of the licence [Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)](http://creativecommons.org/licenses/by-nc-sa/4.0/)_ \n",
"_The present version has been written by Sébastien Gilles and Vincent Rouvreau (Inria)_"
......
......@@ -41,7 +41,7 @@
"void PrintDivision(int arg1, int arg2)\n",
"{\n",
" if (arg2 == 0)\n",
" std::cerr << \"Failure: division by zero!\" << std::endl;\n",
" std::cout << \"Failure: division by zero!\" << std::endl;\n",
" else\n",
" {\n",
" int division ;\n",
......@@ -205,7 +205,7 @@
" if (compute_division(5, 0, quotient, remainder) == 0)\n",
" std::cout << \"5 / 0 = \" << quotient << \" with a remainder of \" << remainder << '.' << std::endl;\n",
" else\n",
" std::cerr << \"Can't divide by 0!\" << std::endl;\n",
" std::cout << \"Can't divide by 0!\" << std::endl;\n",
"}"
]
},
......@@ -812,8 +812,7 @@
" std::cout << GenerateString(\"Hello world!\") << std::endl; \n",
" \n",
" std::string text(\"Hello!\");\n",
" std::cout << GenerateString(text) << std::endl; \n",
" \n",
" std::cout << GenerateString(text) << std::endl;\n",
"}"
]
},
......@@ -940,7 +939,7 @@
" };\n",
" \n",
" std::cout << square(5.) << std::endl;\n",
"}\n"
"}"
]
},
{
......@@ -1404,4 +1403,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
\ No newline at end of file
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment