summaryrefslogtreecommitdiff
path: root/Fundamental_of_Computing_and_Programming_in_C/Chapter09.ipynb
blob: 11735b9266c8ee628a4686396dd569e0b1c7b56f (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
{
 "metadata": {
  "name": "",
  "signature": "sha256:1a0147da7a94fc5ebe7c66bbf21a563cb0bee33c1452a7bcfcbc21f5395d7aab"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "heading",
     "level": 1,
     "metadata": {},
     "source": [
      "Chapter 09 : Parameter Passing Methods"
     ]
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example: 1, Page No.: 5.63"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Call By Value\n",
      "\n",
      "def cube(x):\n",
      "    x=x*x*x\n",
      "    return(x)\n",
      "\n",
      "n=5\n",
      "print \"Cube of %d is\"%n,cube(n)\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "Cube of 5 is 125\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "heading",
     "level": 2,
     "metadata": {},
     "source": [
      "Example: 2, Page No.:5.64"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#Call by reference\n",
      "\n",
      "def interchange(a,b):\n",
      "    t=0\n",
      "    t=a\n",
      "    a=b\n",
      "    b=t\n",
      "    return b,a\n",
      "\n",
      "    \n",
      "i=5\n",
      "j=10\n",
      "print \"i and j values before interchange:\", i, j\n",
      "\n",
      "i=10\n",
      "j=5\n",
      "interchange(i,j)\n",
      "\n",
      "#Result\n",
      "print \"i and j values after interchange:\",i,j\n",
      "\n",
      "print \"i and j avalues after interchange in the function : %d %d \\n\"%interchange(i,j)\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "i and j values before interchange: 5 10\n",
        "i and j values after interchange: 10 5\n",
        "i and j avalues after interchange in the function : 10 5 \n",
        "\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}