summaryrefslogtreecommitdiff
path: root/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb
diff options
context:
space:
mode:
authorThomas Stephen Lee2015-09-04 22:04:10 +0530
committerThomas Stephen Lee2015-09-04 22:04:10 +0530
commit41f1f72e9502f5c3de6ca16b303803dfcf1df594 (patch)
treef4bf726a3e3ce5d7d9ee3781cbacfe3116115a2c /Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb
parent9c9779ba21b9bedde88e1e8216f9e3b4f8650b0e (diff)
downloadPython-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.tar.gz
Python-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.tar.bz2
Python-Textbook-Companions-41f1f72e9502f5c3de6ca16b303803dfcf1df594.zip
add/remove/update books
Diffstat (limited to 'Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb')
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb266
1 files changed, 0 insertions, 266 deletions
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb
deleted file mode 100755
index 21b14f41..00000000
--- a/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb
+++ /dev/null
@@ -1,266 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:2bed6e40cd55f716f11e909c76b0c924a863909239fcbbf975814260bb7b4531"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 1,
- "metadata": {},
- "source": [
- "Chapter 15 : Pointers and Functions"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Call By Value"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 1, Page no. 5.112"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Call by value\n",
- "\n",
- "def change(x,y):\n",
- " x=x+5\n",
- " y=y+10\n",
- " print \"In the function changes a&b is %d,%d\"%(x,y)\n",
- " \n",
- "a=10\n",
- "b=20\n",
- "\n",
- "print \"\\nBefore calling the function a&b is %d,%d\"%(a,b)\n",
- "\n",
- "change(a,b)\n",
- "print \"\\nAfter calling a&b is %d,%d\"%(a,b)\n",
- " "
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Before calling the function a&b is 10,20\n",
- "In the function changes a&b is 15,30\n",
- "\n",
- "After calling a&b is 10,20\n"
- ]
- }
- ],
- "prompt_number": 1
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 2, Page no.5.113"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#program to swap(interchange) the two given variable.\n",
- "\n",
- "def swap(x,y):\n",
- " \n",
- " x=x+y\n",
- " y=x-y\n",
- " x=x-y\n",
- " print \"In swap function x=%d, y=%d\"%(x,y)\n",
- " return y,x\n",
- "\n",
- "a=10\n",
- "b=20\n",
- "\n",
- "print \"Before swap a=%d, b=%d\"%(a,b)\n",
- "\n",
- "\n",
- "print \"\\nAfter the calling the swap function, a=%d,b=%d\"%swap(a,b)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before swap a=10, b=20\n",
- "In swap function x=20, y=10\n",
- "\n",
- "After the calling the swap function, a=10,b=20\n"
- ]
- }
- ],
- "prompt_number": 8
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Call By Reference"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 1, Page.No.5.114"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Call By Reference\n",
- "\n",
- "def change (x,y):\n",
- " x=x+5\n",
- " y=y+10\n",
- " print \"In the function change a&b is %d %d\"%(x,y)\n",
- " return x,y\n",
- "a=10\n",
- "b=20\n",
- "print \"\\nBefore calling the function a&b is %d %d\"%(a,b)\n",
- "\n",
- "\n",
- "print \"After calling the function a&b is %d %d\"%change(a,b)\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "Before calling the function a&b is 10 20\n",
- "In the function change a&b is 15 30\n",
- "After calling the function a&b is 15 30\n"
- ]
- }
- ],
- "prompt_number": 15
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 2, Page No.5.115"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Program to swap(intercahnge) the value of variables.\n",
- "\n",
- "a=10\n",
- "b=20\n",
- "\n",
- "print \"\\nBefore swap a=%d, b=%d\"%(swap(a,b))\n",
- "\n",
- "def swap(x,y):\n",
- " x=x+y\n",
- " y=x-y\n",
- " x=x-y\n",
- " print\"\\nIn swap function x=%d,y=%d\"%(x,y)\n",
- " return y,x\n",
- "\n",
- "print \"\\nAfter calling swap function a=%d, b=%d\"%(b,a)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "\n",
- "In swap function x=20,y=10\n",
- "\n",
- "Before swap a=10, b=20\n",
- "\n",
- "After calling swap function a=20, b=10\n"
- ]
- }
- ],
- "prompt_number": 35
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 3, Page no. 5.115"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Program to interchange the value of variables using call by reference\n",
- "def exchange(m,n):\n",
- " t=m\n",
- " m=n\n",
- " n=t\n",
- " return n,m\n",
- "\n",
- "a,b=input(\"Enter two Numbers: \")\n",
- "\n",
- "print \"Before Exchange a=%d,b=%d\"%(a,b)\n",
- "\n",
- "\n",
- "print \"After Exchange a=%d, b=%d\"%(exchange(b,a))\n"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter two Numbers: 10,20\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before Exchange a=10,b=20\n",
- "After Exchange a=20, b=10\n"
- ]
- }
- ],
- "prompt_number": 3
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file