From 83c1bfceb1b681b4bb7253b47491be2d8b2014a1 Mon Sep 17 00:00:00 2001 From: debashisdeb Date: Fri, 20 Jun 2014 15:42:42 +0530 Subject: removing problem statements --- C++_from_the_Ground/Chapter_22(1).ipynb | 201 +++++++++++++++++++++++++++----- 1 file changed, 171 insertions(+), 30 deletions(-) (limited to 'C++_from_the_Ground/Chapter_22(1).ipynb') diff --git a/C++_from_the_Ground/Chapter_22(1).ipynb b/C++_from_the_Ground/Chapter_22(1).ipynb index 83be7161..8c26974a 100644 --- a/C++_from_the_Ground/Chapter_22(1).ipynb +++ b/C++_from_the_Ground/Chapter_22(1).ipynb @@ -1,6 +1,7 @@ { "metadata": { - "name": "Chapter 22" + "name": "", + "signature": "sha256:53f00d75f5adfa37af0d8067426691c881e1b4ea1e38045c3a67a88230ca00f5" }, "nbformat": 3, "nbformat_minor": 0, @@ -10,24 +11,44 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Chapter 22: The C++ Preprocessor

" + "source": [ + "

Chapter 22: The C++ Preprocessor

" + ] }, { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.1, Page Number: 550

" + "source": [ + "

Example 22.1, Page Number: 550

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implement a function-like macro'''\n\ndef MIN(a,b):\n if aExample 22.2, Page Number: 551

" + "source": [ + "

Example 22.2, Page Number: 551

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implement a function-like macro'''\n#Since macros is implemented here using functions,\n#it wont give a wrong answer.\n\ndef EVEN(a):\n if a%2==0:\n return 1\n else:\n return 0\n\nif EVEN(9+1):\n print \"is even\"\nelse:\n print \"is odd\"", + "input": [ + "\n", + "\n", + "def EVEN(a):\n", + " if a%2==0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "if EVEN(9+1):\n", + " print \"is even\"\n", + "else:\n", + " print \"is odd\"" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "is even\n" + "text": [ + "is even\n" + ] } ], "prompt_number": 3 @@ -55,19 +93,35 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.3, Page Number: 551

" + "source": [ + "

Example 22.3, Page Number: 551

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implement a function-like macro'''\n\ndef EVEN(a):\n if a%2==0:\n return 1\n else:\n return 0\n\nif EVEN(9+1):\n print \"is even\"\nelse:\n print \"is odd\"", + "input": [ + "\n", + "def EVEN(a):\n", + " if a%2==0:\n", + " return 1\n", + " else:\n", + " return 0\n", + "\n", + "if EVEN(9+1):\n", + " print \"is even\"\n", + "else:\n", + " print \"is odd\"" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "is even\n" + "text": [ + "is even\n" + ] } ], "prompt_number": 4 @@ -75,19 +129,31 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.4, Page Number: 553

" + "source": [ + "

Example 22.4, Page Number: 553

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Impementing #if'''\n\ndef MAX():\n return 100\n\nif MAX()>10:\n print \"Extra memory required.\"\n ", + "input": [ + "\n", + "def MAX():\n", + " return 100\n", + "\n", + "if MAX()>10:\n", + " print \"Extra memory required.\"\n", + " " + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "Extra memory required.\n" + "text": [ + "Extra memory required.\n" + ] } ], "prompt_number": 5 @@ -95,19 +161,33 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.5, Page Number: 554

" + "source": [ + "

Example 22.5, Page Number: 554

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Impementing #if/#else'''\n\ndef MAX():\n return 6\n\nif MAX()>10:\n print \"Extra memory required.\"\nelse:\n print \"Current memory OK.\"\n ", + "input": [ + "\n", + "def MAX():\n", + " return 6\n", + "\n", + "if MAX()>10:\n", + " print \"Extra memory required.\"\n", + "else:\n", + " print \"Current memory OK.\"\n", + " " + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "Current memory OK.\n" + "text": [ + "Current memory OK.\n" + ] } ], "prompt_number": 7 @@ -115,19 +195,42 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.6, Page Number: 556

" + "source": [ + "

Example 22.6, Page Number: 556

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implementation of #ifdef and #ifndef'''\n\ndef TOM():\n pass\n\n\ntry:\n TOM()\nexcept NameError:\n print \"Programmer is unknown.\"\nelse:\n print \"Programmer is Tom.\"\n \ntry:\n RALPH()\nexcept NameError:\n print \"RALPH not defined.\"\n ", + "input": [ + "\n", + "def TOM():\n", + " pass\n", + "\n", + "\n", + "try:\n", + " TOM()\n", + "except NameError:\n", + " print \"Programmer is unknown.\"\n", + "else:\n", + " print \"Programmer is Tom.\"\n", + " \n", + "try:\n", + " RALPH()\n", + "except NameError:\n", + " print \"RALPH not defined.\"\n", + " " + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "Programmer is Tom.\nRALPH not defined.\n" + "text": [ + "Programmer is Tom.\n", + "RALPH not defined.\n" + ] } ], "prompt_number": 8 @@ -135,19 +238,32 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.7, Page Number: 558

" + "source": [ + "

Example 22.7, Page Number: 558

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implement __LINE__ '''\n\nimport inspect\n\n#Returns the current line number in our program.\ndef lineno():\n return inspect.currentframe().f_back.f_lineno\n \nprint lineno()+200\n", + "input": [ + "\n", + "import inspect\n", + "\n", + "#Returns the current line number in our program.\n", + "def lineno():\n", + " return inspect.currentframe().f_back.f_lineno\n", + " \n", + "print lineno()+200\n" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "209\n" + "text": [ + "209\n" + ] } ], "prompt_number": 9 @@ -155,19 +271,31 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.8, Page Number: 559

" + "source": [ + "

Example 22.8, Page Number: 559

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implemention # operator'''\n\ndef mkstr(s):\n return str(s)\n\n#Result\nprint mkstr('I like C++')\n", + "input": [ + "\n", + "\n", + "def mkstr(s):\n", + " return str(s)\n", + "\n", + "#Result\n", + "print mkstr('I like C++')\n" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "I like C++\n" + "text": [ + "I like C++\n" + ] } ], "prompt_number": 10 @@ -175,19 +303,32 @@ { "cell_type": "markdown", "metadata": {}, - "source": "

Example 22.9, Page Number: 560

" + "source": [ + "

Example 22.9, Page Number: 560

" + ] }, { "cell_type": "code", "collapsed": false, - "input": "'''Implemention # operator'''\n\ndef concat(a,b):\n return a+b\n#Variable declaration\nxy=10\n\n#Result\nexec(\"print %s\")%concat('x','y')", + "input": [ + "\n", + "def concat(a,b):\n", + " return a+b\n", + "#Variable declaration\n", + "xy=10\n", + "\n", + "#Result\n", + "exec(\"print %s\")%concat('x','y')" + ], "language": "python", "metadata": {}, "outputs": [ { "output_type": "stream", "stream": "stdout", - "text": "10\n" + "text": [ + "10\n" + ] } ], "prompt_number": 11 @@ -195,7 +336,7 @@ { "cell_type": "code", "collapsed": false, - "input": "", + "input": [], "language": "python", "metadata": {}, "outputs": [] -- cgit