diff options
Diffstat (limited to 'Practical_C_Programming/Chapter_11_1.ipynb')
-rw-r--r-- | Practical_C_Programming/Chapter_11_1.ipynb | 77 |
1 files changed, 66 insertions, 11 deletions
diff --git a/Practical_C_Programming/Chapter_11_1.ipynb b/Practical_C_Programming/Chapter_11_1.ipynb index e3193adb..1dc24c59 100644 --- a/Practical_C_Programming/Chapter_11_1.ipynb +++ b/Practical_C_Programming/Chapter_11_1.ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "Chapter 11" + "name": "", + "signature": "sha256:e68b678f99332c0d6ad607ce4c8f99007b9b612142be0ab04cb6c8b4b0cb5969" }, "nbformat": 3, "nbformat_minor": 0, @@ -11,25 +12,41 @@ "cell_type": "heading", "level": 1, "metadata": {}, - "source": "Chapter 11: Bit operations" + "source": [ + "Chapter 11: Bit operations" + ] }, { "cell_type": "heading", "level": 3, "metadata": {}, - "source": "Example 11.1, Page number: 193" + "source": [ + "Example 11.1, Page number: 193" + ] }, { "cell_type": "code", "collapsed": false, - "input": "# Example 11.1.py\n# To check whether two numbers are equal to 0 or not\n\n\n# Variable declaration\ni1 = 4\ni2 = 2\n\n# Calculation and result\nif ((i1 != 0) and (i2 != 0)) :\n print ('Both are not zero\\n')", + "input": [ + "\n", + "# Variable declaration\n", + "i1 = 4\n", + "i2 = 2\n", + "\n", + "# Calculation and result\n", + "if ((i1 != 0) and (i2 != 0)) :\n", + " print ('Both are not zero\\n')" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "Both are not zero\n\n" + "text": [ + "Both are not zero\n", + "\n" + ] } ], "prompt_number": 1 @@ -38,19 +55,42 @@ "cell_type": "heading", "level": 3, "metadata": {}, - "source": "Example 11.2, Page number: 201" + "source": [ + "Example 11.2, Page number: 201" + ] }, { "cell_type": "code", "collapsed": false, - "input": "# Example 11.2.py\n# To illustrate the use of bitwise and shift operators\n\n\n# Variable declaration\nHIGH_SPEED = 1 << 7\nDIRECT_CONNECT = 1 << 8\n\nflags = 0\nflags |= HIGH_SPEED\nflags |= DIRECT_CONNECT\n\n# Calculation and result\nif ((flags & HIGH_SPEED) != 0) :\n print ('High speed set\\n')\n\nif ((flags & DIRECT_CONNECT) != 0) :\n print ('Direct connect set\\n')", + "input": [ + "\n", + "# Variable declaration\n", + "HIGH_SPEED = 1 << 7\n", + "DIRECT_CONNECT = 1 << 8\n", + "\n", + "flags = 0\n", + "flags |= HIGH_SPEED\n", + "flags |= DIRECT_CONNECT\n", + "\n", + "# Calculation and result\n", + "if ((flags & HIGH_SPEED) != 0) :\n", + " print ('High speed set\\n')\n", + "\n", + "if ((flags & DIRECT_CONNECT) != 0) :\n", + " print ('Direct connect set\\n')" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "High speed set\n\nDirect connect set\n\n" + "text": [ + "High speed set\n", + "\n", + "Direct connect set\n", + "\n" + ] } ], "prompt_number": 2 @@ -59,19 +99,34 @@ "cell_type": "heading", "level": 3, "metadata": {}, - "source": "Example 11.4, Page number: 207" + "source": [ + "Example 11.4, Page number: 207" + ] }, { "cell_type": "code", "collapsed": false, - "input": "# Example 11.4.py\n# To test a loop counter\n\n\n# Variable declaration\ni = 0x80\n\n# Calculation and result\nif (i != 0) :\n print ('i is %x (%d) \\n' % (i, i))\n i = i >> 1", + "input": [ + "\n", + "\n", + "# Variable declaration\n", + "i = 0x80\n", + "\n", + "# Calculation and result\n", + "if (i != 0) :\n", + " print ('i is %x (%d) \\n' % (i, i))\n", + " i = i >> 1" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "i is 80 (128) \n\n" + "text": [ + "i is 80 (128) \n", + "\n" + ] } ], "prompt_number": 3 |