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.ipynb125
1 files changed, 125 insertions, 0 deletions
diff --git a/Practical_C_Programming/Chapter_19_1.ipynb b/Practical_C_Programming/Chapter_19_1.ipynb
new file mode 100644
index 00000000..f02444d9
--- /dev/null
+++ b/Practical_C_Programming/Chapter_19_1.ipynb
@@ -0,0 +1,125 @@
+{
+ "metadata": {
+ "name": "Chapter 19"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": "Chapter 19: Ancient compilers"
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "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)",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "Area is 6.000000\n\n"
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "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)",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "i is 25\n\n"
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "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))",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "Sum is 6\n\n"
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "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)",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "The name is John Doe\n\n"
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 3,
+ "metadata": {},
+ "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)",
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": "Area is 6.000000\n\n"
+ }
+ ],
+ "prompt_number": 5
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file