summaryrefslogtreecommitdiff
path: root/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter11.ipynb
diff options
context:
space:
mode:
Diffstat (limited to 'C_Programming:_A_Modern_Approach_by_K.N._King/Chapter11.ipynb')
-rwxr-xr-xC_Programming:_A_Modern_Approach_by_K.N._King/Chapter11.ipynb81
1 files changed, 81 insertions, 0 deletions
diff --git a/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter11.ipynb b/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter11.ipynb
new file mode 100755
index 00000000..ce091d42
--- /dev/null
+++ b/C_Programming:_A_Modern_Approach_by_K.N._King/Chapter11.ipynb
@@ -0,0 +1,81 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:74e91fb616db3aa96bac711fa075c7c19a951b52d2e8ba98c61929ac216b2aca"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 11: Pointers"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example maxmin.c, Page 250"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "N=10\n",
+ "def max_min(a,n): #function definition\n",
+ " max=a[0]\n",
+ " min=a[0]\n",
+ " for i in range(n-1): #calculating max and min from list\n",
+ " if(a[i+1]>max):\n",
+ " max=a[i+1]\n",
+ " elif(a[i+1]<min):\n",
+ " min=a[i+1]\n",
+ " return (max,min)\n",
+ "li=raw_input(\"Enter %d numbers: \" % N) #input of numbers from user\n",
+ "b=map(int, li.split())\n",
+ "big,small=max_min(b,N) #call function to calculate max and min\n",
+ "print \"Largest: %d\"%big #print max and min\n",
+ "print \"Smallest: %d\"%small\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter 10 numbers: 34 82 49 102 7 94 23 11 50 31\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Largest: 102\n",
+ "Smallest: 7\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file