summaryrefslogtreecommitdiff
path: root/The_C_Book/Chapter7.ipynb
blob: 07af61e007ed414b145dff40c9847fd66dc5800a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
{
 "metadata": {
  "name": "",
  "signature": "sha256:64783eeed575effedf7614334dd2d387799a93300002feb4bfabb494331b571e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 7: The Preprocessor "
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.1, page no. 215\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "def DOUBLE(x):\n",
      "    return x+x\n",
      "\n",
      "print \"%d\\n\" %(DOUBLE(1))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "2\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.2, page no. 217"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "def TEST(x):\n",
      "    if(not (x)):\n",
      "        print \"test failed.... \"\n",
      "    else:\n",
      "        print \"Test passed...\"\n",
      "\n",
      "TEST(23)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Test passed...\n"
       ]
      }
     ],
     "prompt_number": 2
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example 7.3, page no. 220"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "ULONG_MAX = 4294967295 # MAX LIMIT OF LONG IN C LANG.\n",
      "if ULONG_MAX+1 != 0:\n",
      "    print \"Preprocessor: ULONG_MAX+1 != 0\\n\"\n",
      "if ULONG_MAX+1 != 0:\n",
      "    print \"Runtime: ULONG_MAX+1 != 0\\n\""
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Preprocessor: ULONG_MAX+1 != 0\n",
        "\n",
        "Runtime: ULONG_MAX+1 != 0\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 3
    }
   ],
   "metadata": {}
  }
 ]
}