- Jupyter Notebooks for Computer Science Foundational Concepts (CS1) using C++
- some of the contents are based on the open source textbook: Think C++ by Allen B. Downey
- others are based on https://en.cppreference.com/ and http://cplusplus.com/
- PDF of the textbook can be found at http://www.greenteapress.com/thinkcpp/thinkCScpp.pdf
- each notebook chapter is converted into pdf format and found in pdfs folder
- Linux/MacOS/WSL on Windows (not tested on Windows itself)
- Jupyter Notebook
- xeus-cling notebook kernel to run C++ code in Jupyter
- git client
- G++ compiler
- VS Code
-
Note: these libraries and tools need to be installed just once, if you've Jupyter Notebook with C++, you can safely ignore this section
-
git client is already available on Mac and Linux
-
install Miniconda: https://conda.io/miniconda.html
-
open a terminal/shell and run the following commands
-
create a virual environment to keep C++ specific installtions seperate from base installation
conda create -n cpp python=3.7 # create virtual env named cpp with Python3.7 support
conda activate cpp #activate the virual environemnt
conda install notebook
conda install -c conda-forge xeus-cling
conda install -c conda-forge jupyter_contrib_nbextensions
conda install -c conda-forge jupyter_nbextensions_configurator
jupyter nbextensions_configurator enable --user
- clone the repository locally once the tools are installed
- open a terminal and cd into this cloned repo and run jupyter notebook
cd <CPP Fundamentals repo folder>
conda activate cpp
jupyter notebook
- Enter ctrl+c to stop jupyter notebook from the terminal where its running from
- $ conda deactivate # to deactivate the virtual env and go back to base installation
- alternatively, VS Code can be used to load and execute notebooks
- VS Code will help you find the right plugins if missing to render and execute notebooks
- Jupyter Notebook doesn't run complete C++ program with main()
- complete demo programs and example solutions are provided in demo_programs folder
- these programs need to be compiled using any C++ compiler (with C++11 or newer standandard)
- open a terminal and run the following commands
- cd into a chapter with with sample program; compile and run the program
cd demo_programs/Ch...
g++ -std=c++17 -o programName inputFile.cpp
./programName
- install C/C++ plugins for VS Code
- open integreted terminal: View -> Terminal and follow the commands above
- you can also click run button on the top right corner for some programs, but not recommended for many programs that are interactive