summaryrefslogtreecommitdiff
path: root/Fundamental_of_Computing_and_Programming_in_C/Chapter16.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/Chapter16.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/Chapter16.ipynb')
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb333
1 files changed, 0 insertions, 333 deletions
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb
deleted file mode 100755
index ab91ce85..00000000
--- a/Fundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb
+++ /dev/null
@@ -1,333 +0,0 @@
-{
- "metadata": {
- "name": "",
- "signature": "sha256:d2add72dea4c498cf89927248000fdbfce0907704975d2bdb6ff1cde1c8f50a7"
- },
- "nbformat": 3,
- "nbformat_minor": 0,
- "worksheets": [
- {
- "cells": [
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Chapter 16 : Pointers and Arrays"
- ]
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 1, Page No.:5.118"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Program to print the value and address of the element\n",
- "\n",
- "a=[10,20,30,40,50]\n",
- "for b in range(0,5):\n",
- " print \"The value of a[%d]=%d\"%(b,a[b])\n",
- " print \"Address of a[%d]=%u\"%(b,id(a[b]))"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The value of a[0]=10\n",
- "Address of a[0]=4299197952\n",
- "The value of a[1]=20\n",
- "Address of a[1]=4299197712\n",
- "The value of a[2]=30\n",
- "Address of a[2]=4299197472\n",
- "The value of a[3]=40\n",
- "Address of a[3]=4299199208\n",
- "The value of a[4]=50\n",
- "Address of a[4]=4299198968\n"
- ]
- }
- ],
- "prompt_number": 4
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 2, Page No.: 5.119"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Program to print the value and the address of the element using pointer with function\n",
- "\n",
- "a=[10,20,30,40,50]\n",
- "\n",
- "for c in range(0,5):\n",
- " print \"The Value of a[%d]=%d\"%(c,a[c])\n",
- " print \"The address of a[%d]=%u\"%(c,id(b))\n",
- "def value(b):\n",
- " b=''\n",
- " id(b)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "The Value of a[0]=10\n",
- "The address of a[0]=4296527248\n",
- "The Value of a[1]=20\n",
- "The address of a[1]=4296527248\n",
- "The Value of a[2]=30\n",
- "The address of a[2]=4296527248\n",
- "The Value of a[3]=40\n",
- "The address of a[3]=4296527248\n",
- "The Value of a[4]=50\n",
- "The address of a[4]=4296527248\n"
- ]
- }
- ],
- "prompt_number": 58
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example:3, Page No,: 5.120"
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Program to add the sum of number using pointer\n",
- "\n",
- "a=[10,20,30,40,50]\n",
- "\n",
- "b=total=0\n",
- "c=id(c)\n",
- "\n",
- "for b in range(0,5):\n",
- " print \"Enter the number %d: \"%(b+1)\n",
- " a[b]=input()\n",
- " \n",
- "c=a\n",
- "for b in range(0,5):\n",
- " total=total+c[b]\n",
- " c[b]=c[b]+1\n",
- "\n",
- "print \"Total= %d\"%(total)"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the number 1: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "10\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the number 2: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "20\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the number 3: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "30\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the number 4: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "40\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the number 5: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "50\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Total= 150\n"
- ]
- }
- ],
- "prompt_number": 67
- },
- {
- "cell_type": "heading",
- "level": 2,
- "metadata": {},
- "source": [
- "Example: 4, Page No.: 5.121 "
- ]
- },
- {
- "cell_type": "code",
- "collapsed": false,
- "input": [
- "#Program to sort a given number using pointer.\n",
- "\n",
- "arr = []\n",
- "n = input(\"Enter the no. of elements: \")\n",
- "for i in range(0,n):\n",
- " arr.append(0)\n",
- "print \"Enter the element: \" \n",
- "for i in range(0,n):\n",
- " arr[i]=input()\n",
- "print \"Before Sorting:\" \n",
- "for i in range(0,n):\n",
- " print \"%d\"%arr[i],\n",
- " \n",
- "for i in range(0,n):\n",
- " for j in range(i,n):\n",
- " if arr[i]>arr[j]:\n",
- " t = arr[i]\n",
- " arr[i] = arr[j]\n",
- " arr[j] = t\n",
- "print \"\\nAfter Sorting:\"\n",
- "for i in range(0,n):\n",
- " print \"%d\" %arr[i],"
- ],
- "language": "python",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the no. of elements: 5\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Enter the element: \n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "8\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "5\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "7\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "4\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "6\n"
- ]
- },
- {
- "output_type": "stream",
- "stream": "stdout",
- "text": [
- "Before Sorting:\n",
- "8 5 7 4 6 \n",
- "After Sorting:\n",
- "4 5 6 7 8\n"
- ]
- }
- ],
- "prompt_number": 72
- }
- ],
- "metadata": {}
- }
- ]
-} \ No newline at end of file