{
 "metadata": {
  "name": "",
  "signature": "sha256:2bdca20a49e1bad43f6968c764966fb35bc4580bd54570e770e266797cc3ab0e"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 21 : The C Preprocessor"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example: 1, Page No.5.149"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Print square and cube Values by using macro substitutions. \n",
      "def sq(n):\n",
      "    return n*n\n",
      "    \n",
      "    \n",
      "def cube(n):\n",
      "    return n*n*n\n",
      "    \n",
      "\n",
      "a=5\n",
      "b=3\n",
      "s=c=0\n",
      "\n",
      "#Function calling\n",
      "s=sq(a)\n",
      "c=cube(b)\n",
      "\n",
      "#Result\n",
      "print \"Square value of 5 is %d\"%(s)\n",
      "print \"Cube value of 3 is %d\"%(c)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Square value of 5 is 25\n",
        "Cube value of 3 is 27\n"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example: 2, Page No. 5.151"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Print the Values using macro substitution.\n",
      "\n",
      "VAL=40\n",
      "\n",
      "print \"The value is %d\"%VAL\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The value is 40\n"
       ]
      }
     ],
     "prompt_number": 12
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example: 3, Page No.:5.151\n"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Print Value and text using preprocessing.\n",
      "VAL=35\n",
      "\n",
      "HELLO=\"HELLO\"\n",
      "\n",
      "res=VAL-5\n",
      "\n",
      "print \"Res=VAL-5:Res= %d\"%res\n",
      "\n",
      "print \"HELLO\"\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Res=VAL-5:Res= 30\n",
        "HELLO\n"
       ]
      }
     ],
     "prompt_number": 15
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example: 4, Page No.:5.152"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Program to print the value using preprocessors.\n",
      "USD=1\n",
      "UKP=1\n",
      "\n",
      "currency_rate=46\n",
      "currency_rate=100\n",
      "\n",
      "rs=10*currency_rate\n",
      "print  \"The Value of rs is : %d\"%rs\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "The Value of rs is : 1000\n"
       ]
      }
     ],
     "prompt_number": 16
    }
   ],
   "metadata": {}
  }
 ]
}