summaryrefslogtreecommitdiff
path: root/Practical_C_Programming/Chapter_19_1.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'Practical_C_Programming/Chapter_19_1.ipynb')
-rw-r--r--Practical_C_Programming/Chapter_19_1.ipynb106
1 files changed, 89 insertions, 17 deletions
diff --git a/Practical_C_Programming/Chapter_19_1.ipynb b/Practical_C_Programming/Chapter_19_1.ipynb
index f02444d9..00ddd7e8 100644
--- a/Practical_C_Programming/Chapter_19_1.ipynb
+++ b/Practical_C_Programming/Chapter_19_1.ipynb
@@ -1,6 +1,7 @@
{
"metadata": {
- "name": "Chapter 19"
+ "name": "",
+ "signature": "sha256:4ee1b1671641fa0922389d9bf11b94f42d9755534b4f0476bbe2f9ceb3b1bc7e"
},
"nbformat": 3,
"nbformat_minor": 0,
@@ -11,25 +12,41 @@
"cell_type": "heading",
"level": 1,
"metadata": {},
- "source": "Chapter 19: Ancient compilers"
+ "source": [
+ "Chapter 19: Ancient compilers"
+ ]
},
{
"cell_type": "heading",
"level": 3,
"metadata": {},
- "source": "Example 19.1, Page number: 385"
+ "source": [
+ "Example 19.1, Page number: 385"
+ ]
},
{
"cell_type": "code",
"collapsed": false,
- "input": "# Example 19.1.py\n# To calculate the area of a rectangle\n\n\n# Function declaration\ndef area (width, height) :\n return width * height\n\n# Calculation and result\nsize = area (3.0, 2)\nprint ('Area is %f\\n' % size)",
+ "input": [
+ "\n",
+ "# Function declaration\n",
+ "def area (width, height) :\n",
+ " return width * height\n",
+ "\n",
+ "# Calculation and result\n",
+ "size = area (3.0, 2)\n",
+ "print ('Area is %f\\n' % size)"
+ ],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
- "text": "Area is 6.000000\n\n"
+ "text": [
+ "Area is 6.000000\n",
+ "\n"
+ ]
}
],
"prompt_number": 1
@@ -38,19 +55,33 @@
"cell_type": "heading",
"level": 3,
"metadata": {},
- "source": "Example 19.2, Page number: 386"
+ "source": [
+ "Example 19.2, Page number: 386"
+ ]
},
{
"cell_type": "code",
"collapsed": false,
- "input": "# Example 19.2.py\n# To calculate the square of a number\n\n\n# Function declaration\ndef square (s) :\n return s * s\n\n# Calculation and result\ni = square (5)\nprint ('i is %d\\n' % i)",
+ "input": [
+ "\n",
+ "# Function declaration\n",
+ "def square (s) :\n",
+ " return s * s\n",
+ "\n",
+ "# Calculation and result\n",
+ "i = square (5)\n",
+ "print ('i is %d\\n' % i)"
+ ],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
- "text": "i is 25\n\n"
+ "text": [
+ "i is 25\n",
+ "\n"
+ ]
}
],
"prompt_number": 2
@@ -59,19 +90,32 @@
"cell_type": "heading",
"level": 3,
"metadata": {},
- "source": "Example 19.3, Page number: 386"
+ "source": [
+ "Example 19.3, Page number: 386"
+ ]
},
{
"cell_type": "code",
"collapsed": false,
- "input": "# Example 19.3.py\n# To calculate the sum of 3 numbers\n\n\n# Function declaration\ndef sum (i1, i2, i3) :\n return i1 + i2 + i3\n\n# Calculation and result\nprint ('Sum is %d\\n' % sum (1, 2, 3))",
+ "input": [
+ "\n",
+ "# Function declaration\n",
+ "def sum (i1, i2, i3) :\n",
+ " return i1 + i2 + i3\n",
+ "\n",
+ "# Calculation and result\n",
+ "print ('Sum is %d\\n' % sum (1, 2, 3))"
+ ],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
- "text": "Sum is 6\n\n"
+ "text": [
+ "Sum is 6\n",
+ "\n"
+ ]
}
],
"prompt_number": 3
@@ -80,19 +124,33 @@
"cell_type": "heading",
"level": 3,
"metadata": {},
- "source": "Example 19.4, Page number: 387"
+ "source": [
+ "Example 19.4, Page number: 387"
+ ]
},
{
"cell_type": "code",
"collapsed": false,
- "input": "# Example 19.4.py\n# To print the full name of a person\n\n\n# Variable declaration\nfirst = 'John'\nlast = 'Doe'\n\n# Calculation and result\nfull = first + ' ' + last\nprint ('The name is %s\\n' % full)",
+ "input": [
+ "\n",
+ "# Variable declaration\n",
+ "first = 'John'\n",
+ "last = 'Doe'\n",
+ "\n",
+ "# Calculation and result\n",
+ "full = first + ' ' + last\n",
+ "print ('The name is %s\\n' % full)"
+ ],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
- "text": "The name is John Doe\n\n"
+ "text": [
+ "The name is John Doe\n",
+ "\n"
+ ]
}
],
"prompt_number": 4
@@ -101,19 +159,33 @@
"cell_type": "heading",
"level": 3,
"metadata": {},
- "source": "Example 19.5, Page number: 390"
+ "source": [
+ "Example 19.5, Page number: 390"
+ ]
},
{
"cell_type": "code",
"collapsed": false,
- "input": "# Example 19.5.py\n# To calculate the area of a rectangle\n\n\n# Function declaration\ndef area (width, height) :\n return width * height\n\n# Calculation and result\nsize = area (3.0, 2.0)\nprint ('Area is %f\\n' % size)",
+ "input": [
+ "\n",
+ "# Function declaration\n",
+ "def area (width, height) :\n",
+ " return width * height\n",
+ "\n",
+ "# Calculation and result\n",
+ "size = area (3.0, 2.0)\n",
+ "print ('Area is %f\\n' % size)"
+ ],
"language": "python",
"metadata": {},
"outputs": [
{
"output_type": "stream",
"stream": "stdout",
- "text": "Area is 6.000000\n\n"
+ "text": [
+ "Area is 6.000000\n",
+ "\n"
+ ]
}
],
"prompt_number": 5