summaryrefslogtreecommitdiff
path: root/Fundamental_of_Computing_and_Programming_in_C
diff options
context:
space:
mode:
authorhardythe12015-04-07 15:58:05 +0530
committerhardythe12015-04-07 15:58:05 +0530
commitc7fe425ef3c5e8804f2f5de3d8fffedf5e2f1131 (patch)
tree725a7d43dc1687edf95bc36d39bebc3000f1de8f /Fundamental_of_Computing_and_Programming_in_C
parent62aa228e2519ac7b7f1aef53001f2f2e988a6eb1 (diff)
downloadPython-Textbook-Companions-c7fe425ef3c5e8804f2f5de3d8fffedf5e2f1131.tar.gz
Python-Textbook-Companions-c7fe425ef3c5e8804f2f5de3d8fffedf5e2f1131.tar.bz2
Python-Textbook-Companions-c7fe425ef3c5e8804f2f5de3d8fffedf5e2f1131.zip
added books
Diffstat (limited to 'Fundamental_of_Computing_and_Programming_in_C')
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter01.ipynb578
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter02.ipynb767
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter03.ipynb440
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter04.ipynb1337
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter05.ipynb987
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter06.ipynb1424
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter07.ipynb254
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb420
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter09.ipynb109
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter10.ipynb372
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter11.ipynb304
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter12.ipynb829
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter13.ipynb57
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter14.ipynb234
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb266
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb333
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter17.ipynb310
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter18.ipynb490
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter19.ipynb126
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter20.ipynb61
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb174
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter22.ipynb2300
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/README.txt10
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Calculation.pngbin0 -> 75696 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even.pngbin0 -> 64818 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_1.pngbin0 -> 64818 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_2.pngbin0 -> 64818 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_3.pngbin0 -> 64818 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line.pngbin0 -> 112481 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_1.pngbin0 -> 112481 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_2.pngbin0 -> 112481 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_3.pngbin0 -> 112481 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_4.pngbin0 -> 112481 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Standard_Deviation.pngbin0 -> 117100 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi.pngbin0 -> 77814 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi_1.pngbin0 -> 77814 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers.pngbin0 -> 57166 bytes
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers_with_A.pngbin0 -> 51307 bytes
38 files changed, 12182 insertions, 0 deletions
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter01.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter01.ipynb
new file mode 100755
index 00000000..8e50e4de
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter01.ipynb
@@ -0,0 +1,578 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e61d5eac9962a1b27acd93d08c5b466532db593eb946c997e161cd14ea1acee1"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 01 : Operators and Expressions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1: Page No.:4.35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Usage of Arithmetic operators\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=10\n",
+ "j=20\n",
+ "\n",
+ "#the sum value of variables i and j stores in k variable \n",
+ "k=i+j\n",
+ "\n",
+ "#Result\n",
+ "print \"Value of k is %d\"%(k)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value of k is 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2: Page No.:4.35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Demonstrations on arithmetic operators\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "a,b,c,d=input(\"Enter values of a, b, c, d: \")\n",
+ "\n",
+ "#Calculation\n",
+ "a+=(b*c)+d\n",
+ "\n",
+ "#Result\n",
+ "print \"Value of a = %d \"%(a)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter values of a, b, c, d ,e: 12,90,56,43\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value of a = 5095 \n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3: Page No.:4.36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find out all arithmetic operation on two given values\n",
+ "\n",
+ "#Variable Declaration\n",
+ "sum=sub=mul=rem=0\n",
+ "div=0.0\n",
+ "a=0\n",
+ "#User Input\n",
+ "b,c,d=input(\"Enter the values of b, c, d: \")\n",
+ "\n",
+ "sum = b + c\n",
+ "sub = b - c\n",
+ "mul = b * c\n",
+ "div = b/c\n",
+ "rem = b % d\n",
+ "\n",
+ "print \"Sum = %d, Sub = %d, Mul = %d, Div = %f\"%(sum,sub,mul,div)\n",
+ "print \"Remainder of division of b & d is %d\"%(rem)\n",
+ "print \"a=%d\"%(a)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the values of b, c, d: 2,6,45\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sum = 8, Sub = -4, Mul = 12, Div = 0.000000\n",
+ "Remainder of division of b & d is 2\n",
+ "a=0\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4: Page No.: 4.38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to use various relational operators\n",
+ "\n",
+ "#!=,==,>=,<= are assignment operator\n",
+ "\n",
+ "print \"Condition : Return values\"\n",
+ "print \" 5!=5 : %5d\"%(5!=5) \n",
+ "print \" 5==5 : %5d\"%(5==5)\n",
+ "print \" 5>=5 : %5d\"%(5>=5)\n",
+ "print \" 5<=5 : %5d\"%(5<=50)\n",
+ "print \" 5!=3 : %5d\"%(5!=3)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Condition : Return values\n",
+ " 5!=5 : 0\n",
+ " 5==5 : 1\n",
+ " 5>=5 : 1\n",
+ " 5<=5 : 1\n",
+ " 5!=3 : 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5: Page No.:4.39"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Demonstrate of logical operator\n",
+ "\n",
+ "#Variable Declaration\n",
+ "c1=c2=c3=0\n",
+ "\n",
+ "#USer Input\n",
+ "c1,c2,c3=input(\"Enter Values of C1, C2 and C3: \")\n",
+ "print \"\\n\"\n",
+ "\n",
+ "if (c1<c2) and (c1<c3):\n",
+ " print \"C1 is less than C2 and C3\"\n",
+ "\n",
+ "if not(c1) < (c2 ):\n",
+ " print \"C1 is greater than C2\"\n",
+ " \n",
+ "if ((c1 < c2 or c1 < c3)):\n",
+ " print \"C1 is less than C2 or C3 or both\"\n",
+ " \n",
+ "#else:\n",
+ " # print \"Something went wrong. Check\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Values of C1, C2 and C3: 45,32,98\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "C1 is greater than C2\n",
+ "C1 is less than C2 or C3 or both\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6: Page No.: 4.40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Demonstration of assignment operator\n",
+ "\n",
+ "#Variable Declaration\n",
+ "i=4\n",
+ "j=5\n",
+ "\n",
+ "#'=' is assignment operator\n",
+ "i=j\n",
+ "k=i\n",
+ "\n",
+ "#Result\n",
+ "print \"K = %d\"%(k)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "K = 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 44
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7: Page No.:4.42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using Increment and Decrement Operator.\n",
+ "\n",
+ "#Variable Declaration\n",
+ "a=10\n",
+ "\n",
+ "#There is no post and pre increment in python\n",
+ "#There is no post and pre decrement in python\n",
+ "\n",
+ "#Result\n",
+ "print \"The Value of a = %d\"%(a)\n",
+ "print \"Increment of a = %d\"%(a+1)\n",
+ "print \"Decrement of a = %d\"%(a-1)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Value of a = 10\n",
+ "Increment of a = 11\n",
+ "Decrement of a = 9\n"
+ ]
+ }
+ ],
+ "prompt_number": 50
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8: Page No.:4.42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using increment and decrement operators\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "i=3\n",
+ "j=4\n",
+ "\n",
+ "#No Pre Decrement and Pre Increment in python\n",
+ "\n",
+ "i=i+1 #Increment value\n",
+ "j=j-1 #Decrement value\n",
+ "\n",
+ "k=i+j\n",
+ "\n",
+ "#Result\n",
+ "print \"i = %d, j = %d, k = %d\"%(i,j,k)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "i = 4, j = 3, k = 7\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9: Page No.: 4.46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to illustrate sizeof operator\n",
+ "\n",
+ "import sys\n",
+ "\n",
+ "num=int(1234567890)\n",
+ "dec=float(0.123456)\n",
+ "ext=0.123456789\n",
+ "ltr='A'\n",
+ "string=\"Something to write home about....\"\n",
+ "class struct():\n",
+ " a=0\n",
+ "boy=struct()\n",
+ "\n",
+ "#Result\n",
+ "print \"Size of num is in %d bytes.\"%(sys.getsizeof(num))\n",
+ "print \"Size of dec is in %d bytes.\"%(sys.getsizeof(dec))\n",
+ "print \"Size of ext double is in %d bytes.\"%(sys.getsizeof(ext))\n",
+ "print \"Size of ltr char is in %d bytes.\"%(sys.getsizeof(ltr))\n",
+ "print \"Size of the string is in %d bytes.\"%(sys.getsizeof(string))\n",
+ "print \"Size of struct is in %d bytes.\"%(sys.getsizeof(struct()))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Size of num is in 12 bytes.\n",
+ "Size of dec is in 16 bytes.\n",
+ "Size of ext double is in 16 bytes.\n",
+ "Size of ltr char is in 22 bytes.\n",
+ "Size of the string is in 54 bytes.\n",
+ "Size of struct is in 32 bytes.\n"
+ ]
+ }
+ ],
+ "prompt_number": 70
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 1: PageNo.:4.52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Convert number of days to months and days\n",
+ "\n",
+ "#Variable Declaration\n",
+ "m=0\n",
+ "d=0\n",
+ "\n",
+ "#User Input\n",
+ "nd=input(\"Enter the number of days= \")\n",
+ "\n",
+ "\n",
+ "m=nd/30\n",
+ "d=nd%30\n",
+ "\n",
+ "#Result\n",
+ "print \"Number of months...\", m\n",
+ "print \"Number of days...\", d"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of days= 215\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of months... 7\n",
+ "Number of days... 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 74
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 2: Page No.:4.53"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Calculate Salesman Salary\n",
+ "\n",
+ "#Variable Declaration\n",
+ "BASIC=2500\n",
+ "BONUS_RATE=200\n",
+ "COM=0.02\n",
+ "\n",
+ "qty=0\n",
+ "GS=price=Bonus=Comm=0.0\n",
+ "#User input\n",
+ "qty,price=input(\"Enter the number of items Sold and Price...: \")\n",
+ "\n",
+ "Bonus=BONUS_RATE*qty\n",
+ "Comm=COM*qty*price\n",
+ "\n",
+ "GS=BASIC+Bonus+Comm\n",
+ "\n",
+ "print \"Bonus.... %6.2f\"%(Bonus)\n",
+ "\n",
+ "print \"Commission.... %6.2f\"%(Comm)\n",
+ "\n",
+ "print \"Gross Salary... %6.2f\"%(GS)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of items Sold and Price...: 10,200\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Bonus.... 2000.00\n",
+ "Commission.... 40.00\n",
+ "Gross Salary... 4540.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 75
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 3: Page No.:4.54"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Post increment using different storage classes\n",
+ "\n",
+ "#Defining function\n",
+ "def postinc():\n",
+ " x=1\n",
+ " print \"X = %d\" %(x)\n",
+ " x=x+1\n",
+ " \n",
+ "#Call Function\n",
+ "postinc()\n",
+ "postinc()\n",
+ "postinc()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "X = 1\n",
+ "X = 1\n",
+ "X = 1\n"
+ ]
+ }
+ ],
+ "prompt_number": 77
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter02.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter02.ipynb
new file mode 100755
index 00000000..1aa8a278
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter02.ipynb
@@ -0,0 +1,767 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:e63878167c3dee16dba0cb7cf1eb45b07d3e347ca99ab3a68339c448d68bdb66"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 02 : Managing Input and Output Operators"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1, Page No 4.56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Testing Characters\n",
+ "\n",
+ "#Variable Declaration\n",
+ "ch=''\n",
+ "\n",
+ "#User Input\n",
+ "ch=raw_input(\"Give any Character as a input: \")\n",
+ "\n",
+ "if (ch.isalpha()>0): #Checking whether the character is alphabet\n",
+ " print ch,\"is a alphabet\"\n",
+ " \n",
+ "elif(ch.isdigit()>0): #Checking whether the character is digit\n",
+ " print ch,\"is a digit\"\n",
+ " \n",
+ "else: #else print alphanumeric\n",
+ " print ch,\"is a alphanumeric\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give any Character as a input: a\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a is a alphabet\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2, Page No 4.57"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Convert Uppercase to Lowercase and Viceversa\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "ch=''\n",
+ "\n",
+ "\n",
+ "#User Input\n",
+ "ch= raw_input(\"Give the input in lower case or upper case: \")\n",
+ "\n",
+ "if(ch.islower()): #Converting lowercase if input is uppercase\n",
+ " print ch.upper(), \"is a upper case character\"\n",
+ " \n",
+ "else: #else print lowercase\n",
+ " print ch.lower(), \"is a lower case character\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the input in lower case or upper case: s\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "S is a upper case character\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3, Page No 4.58"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using input function\n",
+ "\n",
+ "scientist=''\n",
+ "\n",
+ "scientist = raw_input(\"Enter Name: \")\n",
+ "print \"Print the name: \", scientist\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Name: Abdul kalam\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Print the name: Abdul kalam\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4, Page No 4.62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Count numbers of entered numbers\n",
+ "\n",
+ "#Variable declaration\n",
+ "i=0\n",
+ "j=10\n",
+ "k=0\n",
+ "\n",
+ "#getting input from user \n",
+ "j=int(raw_input(\"Give input for j \"))\n",
+ "k=int(raw_input(\"Give input for k \"))\n",
+ "i=int(raw_input(\"Give input for i \"))\n",
+ "\n",
+ "i= i, j, k #assigning the user input in to a variable\n",
+ "\n",
+ "#Result\n",
+ "print \"No. of given input values:\", len(i) #counting length of the given input\n",
+ "print \"The Value of j and k is \", j, k #printing the values of input"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give input for j 56\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give input for k 32\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give input for i 10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "No. of given input values: 3\n",
+ "The Value of j and k is 56 32\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5, Page No 4.65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Print a statement using print\n",
+ "\n",
+ "print \"VRB Publishers\" #Printing statement"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "VRB Publishers\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6, Page No 4.65"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Adding two numbers\n",
+ "\n",
+ "#variable declaration\n",
+ "\n",
+ "a=6\n",
+ "b=8\n",
+ "c= a+b #Adding a, b and stores in c \n",
+ "\n",
+ "#Result\n",
+ "print \"Addition of two numbers is : \", c"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Addition of two numbers is : 14\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7, Page No 4.66"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Reading and Displaying Details of a student\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "sno=m1=m2=m3=0\n",
+ "name=['20']\n",
+ "total=0\n",
+ "avg=0.0\n",
+ "\n",
+ "#User Inputs\n",
+ "sno=int(raw_input(\"Give Student serial no. \"))\n",
+ "name=raw_input(\"Student Name : \")\n",
+ "m1=int(raw_input(\"Student Mark 1: \"))\n",
+ "m2=int(raw_input(\"Student Mark 2: \"))\n",
+ "m3=int(raw_input(\"Student Mark 3: \"))\n",
+ "\n",
+ "total=float(m1+m2+m3) #Calculation of marks\n",
+ "\n",
+ "avg=\"%.2f\"%float(total/3.0) #Average\n",
+ "\n",
+ "#Result\n",
+ "print '\\n'\"Student serial No.:\", sno\n",
+ "print \"Student Name:\", name\n",
+ "print \"Student's Marks:\", m1, m2, m3\n",
+ "print \"Total:\", total\n",
+ "print \"Average:\", avg "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give Student serial no. 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Student Name : Raja\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Student Mark 1: 90\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Student Mark 2: 95\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Student Mark 3: 98\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Studnt serial No.: 1\n",
+ "Student Name: Raja\n",
+ "Student's Marks: 90 95 98\n",
+ "Total: 283.0\n",
+ "Average: 94.33\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8, Page No:4.71"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Display quotient and reminder of given input\n",
+ "\n",
+ "#variable declaration\n",
+ "\n",
+ "a=b=q=r=0\n",
+ "\n",
+ "#User input\n",
+ "a=int(raw_input(\"Give input for a: \"))\n",
+ "b=int(raw_input(\"Give input for b: \"))\n",
+ "\n",
+ "q=float(a/b) #Calculation for Quotient\n",
+ "\n",
+ "r=float(a-q*b) #Calculation for Reminder\n",
+ "\n",
+ "#Result\n",
+ "print \"Quotient of a and b is :\",q\n",
+ "print \"Reminder of a and b is :\",r"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give input for a: 39\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give input for b: 7\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quotient of a and b is : 5.0\n",
+ "Reminder of a and b is : 4.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9, Page No:4.73"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Slope and Midpoint of a line\n",
+ "\n",
+ "#Variable declaration\n",
+ "\n",
+ "x=x1=y1=x2=y2=slope=0.0\n",
+ "\n",
+ "#User input1\n",
+ "\n",
+ "x1=int(raw_input(\"Give point X1: \"))\n",
+ "y1=int(raw_input(\"Give point Y1: \"))\n",
+ "\n",
+ "\n",
+ "#User input2\n",
+ "\n",
+ "x2=int(raw_input('\\n'\"Give point X2: \"))\n",
+ "y2=int(raw_input(\"Give point Y2: \"))\n",
+ "\n",
+ "slope =(y2-y1)/(x2-x1) #Calculation for Slope\n",
+ "\n",
+ "#Calculation for Midpoints\n",
+ "x=float(x1+x2)/2.0\n",
+ "y=float(y1+y2)/2.0\n",
+ "\n",
+ "#Result\n",
+ "print '\\n' \"Slope of a line is :\", slope\n",
+ "print \"Midpoint of a line is :\", x,y"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give point X1: 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give point Y1: 20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Give point X2: 30\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give point Y2: 40\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Slope of a line is : 1\n",
+ "Midpoint of a line is : 20.0 30.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 10, Page No:4.73"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Average of Given N Numbers\n",
+ "\n",
+ "#Variable Declaration\n",
+ "n=0.0\n",
+ "x=0\n",
+ "total=0\n",
+ "avg=0.0\n",
+ "\n",
+ "#UserInput\n",
+ "\n",
+ "n=int(raw_input(\"Give total number of input: \"))\n",
+ "\n",
+ "print \"Give those\",n ,\"Numbers\"\n",
+ "\n",
+ "for i in range(n): #Looping values of n\n",
+ " i=1\n",
+ " x=input() #Values for n\n",
+ " total+=x # Adding given numbers\n",
+ " \n",
+ "avg=float(total/n) #Calculating an average of given numbers\n",
+ "\n",
+ "#Result\n",
+ "print \"Sum of given numbers is \", total\n",
+ "print \"Average is \", avg\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give total number of input: 5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give those 5 Numbers\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "17\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "76\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "9\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sum of given numbers is 112\n",
+ "Average is 22.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 11, Page No:4.75"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Temperature Conversion (Fahrenheit to Celsius)\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "F_MIN =0\n",
+ "F_MAX=500\n",
+ "INC=50\n",
+ "fh= F_MIN\n",
+ "\n",
+ "print \"Fahrenheit\" '\\t' \"Celsius\"\n",
+ "while(fh<=F_MAX):\n",
+ " cel =\"%.2f\"%float((fh-(32.0))/1.8) #Calculating Celsius value\n",
+ " print fh,'\\t''\\t', cel\n",
+ " fh=fh+INC #Calculating Fahrenheit value\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Fahrenheit\tCelsius\n",
+ "0 \t\t-17.78\n",
+ "50 \t\t10.00\n",
+ "100 \t\t37.78\n",
+ "150 \t\t65.56\n",
+ "200 \t\t93.33\n",
+ "250 \t\t121.11\n",
+ "300 \t\t148.89\n",
+ "350 \t\t176.67\n",
+ "400 \t\t204.44\n",
+ "450 \t\t232.22\n",
+ "500 \t\t260.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 12, Page No:4.76"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Area of Triangle\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "a=b=c=s=area=0.0\n",
+ "\n",
+ "#User input\n",
+ "\n",
+ "a=int(raw_input(\"First side of Triangle is \"))\n",
+ "b=int(raw_input(\"Second side of Triangle is \"))\n",
+ "c=int(raw_input(\"Third side of Triangle is \"))\n",
+ "\n",
+ "s=(a+b+c)/2.0 #Calculating Size of triangle\n",
+ "\n",
+ "area=\"%.3f\"%float((s*(s-a)*(s-b)*(s-c)) ** 0.5) #Calculating Area of triangle\n",
+ "\n",
+ "#Result\n",
+ "print '\\n',\"Area of Triangle is\",area"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "First side of Triangle is 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Second side of Triangle is 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Third side of Triangle is 10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Area of Triangle is 43.301\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter03.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter03.ipynb
new file mode 100755
index 00000000..34a44d60
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter03.ipynb
@@ -0,0 +1,440 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:92464c4be2e3e810ccda180a900c5ec8bb15a9537c93387b95c317c7709c7b7c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 03 : Decision Making"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1, Page No.:4.79"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using if with multiple statements\n",
+ "\n",
+ "\n",
+ "#Variable Declaration\n",
+ "i=0\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "i =int(raw_input(\"Give the numbers less than 10\"'\\n'))\n",
+ "\n",
+ "if i<=10: #Checking the given value\n",
+ "\n",
+ "#Result \n",
+ " print \"The given value of\", i , \"less than 10\"\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the numbers less than 10\n",
+ "5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "the given value of 5 less than 10\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.: 4.79"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "##Program for interchange two values using if statement\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "a=m=n=0\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "m=int(raw_input(\"Give the value of m\" '\\t'))\n",
+ "n=int(raw_input(\"Give the value of n\" '\\t'))\n",
+ "\n",
+ "if m>=n : #Checking the Given Values\n",
+ " \n",
+ " a=m # method for swapping \n",
+ " m=n\n",
+ " n=a\n",
+ "\n",
+ "#Result\n",
+ "\n",
+ "print \"The Swapped Values of m and n are \", m,a"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of m\t34\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of n\t28\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Swapped Values of m and n are 28 34\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No. 4.81"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#determine the given number is odd or even. \n",
+ "\n",
+ "#Variable Declaration\n",
+ "num=rem=0\n",
+ "\n",
+ "#User Input\n",
+ "num=input(\"Enter the value: \")\n",
+ "rem=num%2 \n",
+ "if rem==0 : #Checking condition\n",
+ "\n",
+ "#Result 1\n",
+ " print \"The given number is Even\"\n",
+ "else :\n",
+ " \n",
+ "#Result 2\n",
+ " print \"The given number is Odd\"\n",
+ " \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the value: 80\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The given number is Even\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page No.:4.81"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Find floating point input using if-else statement\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "years=seconds=0.0\n",
+ "life=0\n",
+ "\n",
+ "years=float(raw_input(\"Give your Age in years: \"))\n",
+ "life=years\n",
+ "if life==0:\n",
+ " print \"The given age is not floating value\"\n",
+ " \n",
+ "else :\n",
+ " seconds=\"%f\"%float(years*365*24*60*60)\n",
+ " print \"You have lived for\", seconds, \"seconds\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give your Age in years: 24\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "You have lived for 756864000.000000 seconds\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 5, Page No. :4.82"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# find biggest among two numbers \n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "i=j=big=0\n",
+ "i,j=input(\"Give two values: \")\n",
+ "\n",
+ "big=i\n",
+ "\n",
+ "if big<j :\n",
+ " big=j\n",
+ " \n",
+ "elif i<j :\n",
+ " big=j \n",
+ " \n",
+ "else:\n",
+ " big = i\n",
+ "\n",
+ "print \"Biggest number of two numbers: \",big\n",
+ "print \"Biggest of two numbers(using else) is: \",big"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give two values: 45,78\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Biggest number of two numbers: 78\n",
+ "Biggest of two numbers(using else) is: 78\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 6, Page No. : 4.84"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Program using nested if....else \n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "n=0\n",
+ "\n",
+ "#User Input\n",
+ "n=int(raw_input(\"Enter the number\"))\n",
+ "\n",
+ "if n==15: #Checking Condition\n",
+ " print \"Play Foot ball\"\n",
+ " \n",
+ "elif n==10:\n",
+ " print \"Play Cricket\"\n",
+ "\n",
+ "else : \n",
+ " print \"Don't Play\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Play Cricket\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 7, Page No. :4.85"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#print the number between 10 and 20\n",
+ "\n",
+ "#Variable declaration\n",
+ "\n",
+ "i=0\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "i=input(\"Enter the number: \")\n",
+ "\n",
+ "if (i>10) & (i<20):\n",
+ " print \"The given value is in between 10 and 20\"\n",
+ "\n",
+ "else :\n",
+ " print \"The given value is greater than 20 and less than 10\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number: 15\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The given value is in between 10 and 20\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 8, Page No. :4.86"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# display the types of characterusing if-else statement\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "chr= raw_input(\"Enter a Single Character: \")\n",
+ "\n",
+ "if( ((chr>='a') & (chr<='z')) | ((chr>='A') & (chr<='Z'))):\n",
+ " print \"Given charactered is an Alphabetic\"\n",
+ " \n",
+ "elif ((chr>='0') & (chr <='9')):\n",
+ " print \"Given Character is a digit\"\n",
+ " \n",
+ "else:\n",
+ " print \"Entered Character is a special character\"\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a Single Character: M\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Given charactered is an Alphabetic\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter04.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter04.ipynb
new file mode 100755
index 00000000..a58b3c75
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter04.ipynb
@@ -0,0 +1,1337 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:cbd54959e18d38695240f376809cd86bcdd3f9c461e014b42a620c0846ec3cbf"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 04 : Branching and Looping"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 1: Page No.:4.88"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# addition of numbers using while loop.\n",
+ "\n",
+ "#Varibale Declaration\n",
+ "\n",
+ "i=1\n",
+ "sum=0\n",
+ "while i<=10: #Checking while loop\n",
+ " sum+=i\n",
+ " i+=1 #Increment of i\n",
+ " \n",
+ " #Result \n",
+ "print \"The Sum of the numbers upto is \",sum"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Sum of the numbers upto is 55\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 2: Page No.: 4.89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import sys\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "i=1\n",
+ "j=0\n",
+ "\n",
+ " \n",
+ "print \"The maximum value of integer is\", sys.maxsize\n",
+ "print \"The Value of integer after overflow is\", sys.maxint-1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ " The maximum value of integer is 2147483647\n",
+ "The Value of integer after overflow is 2147483646\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 3: Page No.: 4.89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Reverse the given number using while loop\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "number=digit=rev=0\n",
+ "\n",
+ "number=input(\"Give the Value: \")\n",
+ "\n",
+ "while(number!=0):\n",
+ " digit=number%10\n",
+ " rev=rev*10+digit\n",
+ " number= number/10\n",
+ " \n",
+ "print \"The reversible value of given number is\", rev\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the Value: 7896\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The reversible value of given number is 6987\n"
+ ]
+ }
+ ],
+ "prompt_number": 33
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 4: Page No.: 4.90"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Simple interest using while loop.\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "p=1\n",
+ "n=1\n",
+ "count=1\n",
+ "\n",
+ "r=si=0.0\n",
+ "\n",
+ "while(count<=3):\n",
+ " p=input(\"Give the value of P\" '\\t')\n",
+ " n=input(\"Give the value of N\"'\\t')\n",
+ " r=float(input(\"Give the value of R\"'\\t'))\n",
+ " \n",
+ " si=\"%.3f\"%float((p*n*r)/100)\n",
+ " \n",
+ " print \"Simple Interest of SI\", si\n",
+ " count=count+1\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of P\t2000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of N\t3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of R\t5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Simple Interest of SI 300.000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of P\t3500\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of N\t6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of R\t1.5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Simple Interest of SI 315.000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of P\t6000\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of N\t2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of R\t3.5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Simple Interest of SI 420.000\n"
+ ]
+ }
+ ],
+ "prompt_number": 41
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 5: Page No.:4.92"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Numbers upto 10 by using the do..while loop\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "i=1\n",
+ "sum=0\n",
+ "\n",
+ "while True:\n",
+ "\tsum+=i\n",
+ "\ti+=1\n",
+ "\tif(i>10):\n",
+ "\t\tbreak\n",
+ "print \"Sum of the numbers upto 10 is\", sum \n",
+ " \n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sum of the numbers upto 10 is 55\n"
+ ]
+ }
+ ],
+ "prompt_number": 42
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 6: Page No.: 4.92"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#print n numbers using do...while loop\n",
+ "\n",
+ "i=0\n",
+ "\n",
+ "n=input(\"Enter the number: \")\n",
+ "\n",
+ "while True:\n",
+ " print \"The numbers are: \",i\n",
+ " i=i+1\n",
+ " if(i>=n):\n",
+ " break\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number: 6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The numbers are: 0\n",
+ "The numbers are: 1\n",
+ "The numbers are: 2\n",
+ "The numbers are: 3\n",
+ "The numbers are: 4\n",
+ "The numbers are: 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 73
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 7: page no.: 4.95"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Addition of number upto 10 using for loop\n",
+ "\n",
+ "i=sum=0\n",
+ "\n",
+ "for i in range (0,11):\n",
+ "\tsum+=i\n",
+ "\ti+=1\n",
+ "\n",
+ "print \"The addition of given numbers\",sum\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The addition of given numbers 55\n"
+ ]
+ }
+ ],
+ "prompt_number": 75
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 8: Page No.:4.96"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#print n numbers using for...loop structure\n",
+ "\n",
+ "n=int(raw_input(\"Give Values of n: \"))\n",
+ "i=0\n",
+ "for i in range(0,n):\n",
+ " print \"The Given numbers are: \",i\n",
+ "\n",
+ "\t"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give Values of n: 5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Given numbers are: 0\n",
+ "The Given numbers are: 1\n",
+ "The Given numbers are: 2\n",
+ "The Given numbers are: 3\n",
+ "The Given numbers are: 4\n"
+ ]
+ }
+ ],
+ "prompt_number": 82
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 9: Page No.:4.97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#student marks and average using for loop..\n",
+ "\n",
+ "a=b=c=d=e=total=0\n",
+ "\n",
+ "avg=0.0\n",
+ "\n",
+ "m=input(\"Enter the number of Students:\")\n",
+ "\n",
+ "print \"Enter the marks of the five subjects: \"'\\n'\n",
+ "\n",
+ "for i in range (m): \n",
+ " i+=1\n",
+ " print \"\\nStudent:\",i,\"\\n\"\n",
+ " \n",
+ " a,b,c,d,e=input(\"Enter the Student mark1: \") \n",
+ " \n",
+ " if ((a,b,c,d,e)!=0) :\n",
+ " total=a+b+c+d+e\n",
+ " avg=\"%.3f\"%float(total/5)\n",
+ " print \"Total marks of the student:\", total\n",
+ " print \"Average marks of the students: \",avg\n",
+ " \n",
+ " else :\n",
+ " print \"Entered data is invalid\"\n",
+ " \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of Students:3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the marks of the five subjects: \n",
+ "\n",
+ "\n",
+ "Student: 1 \n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student mark1: 78,56,90,59,87\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total marks of the student: 370\n",
+ "Average marks of the students: 74.000\n",
+ "\n",
+ "Student: 2 \n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student mark1: 49,87,60,57,93\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total marks of the student: 346\n",
+ "Average marks of the students: 69.000\n",
+ "\n",
+ "Student: 3 \n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student mark1: 89,100,80,97,65\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total marks of the student: 431\n",
+ "Average marks of the students: 86.000\n"
+ ]
+ }
+ ],
+ "prompt_number": 89
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 10: Page No.:4.98"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Nested for loop\n",
+ "\n",
+ "for i in range(1,4):\n",
+ " for j in range(1,4):\n",
+ " print \"%d\"%(j),\n",
+ " print \"\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1 2 3 \n",
+ "\n",
+ "1 2 3 \n",
+ "\n",
+ "1 2 3 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 112
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 11: Page No.:4.99"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#student details using nested for loop..\n",
+ "\n",
+ "FIRST=300\n",
+ "SECOND=200\n",
+ "rollno=marks=total=0\n",
+ "\n",
+ "n=input(\"Enter the number of Students: \")\n",
+ "m=input(\"Enter the number of subjects: \")\n",
+ "\n",
+ "for i in range(n):\n",
+ " i+=(+1)\n",
+ " rollno=int(raw_input(\"Enter the student roll number: \"))\n",
+ " total=0\n",
+ " print \"Enter marks of\",m, \"subjects for Roll no: \",rollno\n",
+ " for j in range(m):\n",
+ " marks=int(raw_input(\"Give marks: \"))\n",
+ " total= total+marks\n",
+ " \n",
+ " print \"total marks\", total\n",
+ " if(total>=FIRST):\n",
+ " print \"(First Class)\"'\\n'\n",
+ " elif(total>=SECOND):\n",
+ " print \"(Second Class)\"'\\n'\n",
+ " else:\n",
+ " print \"Fail\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of Students: 2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of subjects: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the student roll number: 201\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter marks of 5 subjects for Roll no: 201\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 90\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 78\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 90\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 68\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 89\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "total marks 415\n",
+ "(First Class)\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the student roll number: 202\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter marks of 5 subjects for Roll no: 202\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 40\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 50\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 49\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 39\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give marks: 47\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "total marks 225\n",
+ "(Second Class)\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 85
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 12: Page No.: 4.103"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Demonstrate switch case\n",
+ "\n",
+ "a=1\n",
+ "if a==1:\n",
+ " print \"I am in case 1\"'\\n'\n",
+ "elif a==2:\n",
+ " print \"I am in case2\"'\\n'\n",
+ "else:\n",
+ " print \"I am in case default\"'\\n'"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "I am in case 1\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 115
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 13: Page No.:4.104"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to use the computer as calculator\n",
+ "\n",
+ "a=b=c=0\n",
+ "\n",
+ "op=raw_input(\"Give the option for calculation like +(ADD), -(SUB), *(MUL), /(DIV): \")\n",
+ "a=input(\"Enter the value of a \")\n",
+ "b=input(\"Enter the value of b \")\n",
+ "\n",
+ "#Calculation\n",
+ "if (op=='+'):\n",
+ " c=a+b\n",
+ " print \"Result of C\", c \n",
+ "elif(op=='-'):\n",
+ " c=a-b\n",
+ " print \"Result of C\", c\n",
+ "elif(op=='*'):\n",
+ " c=a*b\n",
+ " print \"Result of C\", c\n",
+ "else:\n",
+ " c=a/b\n",
+ " print \"Result of C\", c\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the option for calculation like +(ADD), -(SUB), *(MUL), /(DIV): +\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the value of a 20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the value of b 10\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Result of C 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 118
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 14: Page No.:4.105"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find even or odd numbers \n",
+ "\n",
+ "#USer Input\n",
+ "a=input(\"Enter a number: \")\n",
+ "\n",
+ "if a%2==0 : \n",
+ " print \" The number is even. \"\n",
+ "else :\n",
+ " print \"The number is odd.\" \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a number: 89\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The number is odd.\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 15: Page No.:4.106"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to count number of 0s, 1s, blank spaces and other characters\n",
+ "\n",
+ "\n",
+ "txt=[30]\n",
+ "count =0 \n",
+ "txt=raw_input(\"Enter Numbers\")\n",
+ "\n",
+ "print \"Total Spaces : %d\"%txt.count(' ')\n",
+ "print \"Total of 1's : %d\"%txt.count('1')\n",
+ "print \"Total of 0's : %d\"%txt.count('0')\n",
+ "print \"String Length : %d\"%len(txt)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Numbers120010 09100110\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Total Spaces : 2\n",
+ "Total of 1's : 5\n",
+ "Total of 0's : 7\n",
+ "String Length : 16\n"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 16: Page No.: 4.108"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Print the number upto 5 using break statement\n",
+ "\n",
+ "for i in range(1,10):\n",
+ " if i==6:\n",
+ " break\n",
+ " print i,"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1 2 3 4 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 120
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 17: Page No.: 4.109"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to calculate the sum of the given positive numbers\n",
+ "\n",
+ "i=n=sum=0\n",
+ "\n",
+ "for i in range(0,5):\n",
+ " n=int(raw_input(\"Give any value of n \"))\n",
+ " if n<0:\n",
+ " continue\n",
+ " else:\n",
+ " sum+=n\n",
+ " \n",
+ "print \"\\nSum is\", sum"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give any value of n 10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give any value of n 15\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give any value of n 25\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give any value of n -10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give any value of n 50\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Sum is 100\n"
+ ]
+ }
+ ],
+ "prompt_number": 124
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example 18: Page No.:4.113"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using goto statement\n",
+ "\n",
+ "a=input(\"Give the Value of a \")\n",
+ "b=input(\"Give the value of b \")\n",
+ "\n",
+ "if a==b:\n",
+ " print \"A and B are equal\"\n",
+ "else:\n",
+ " print \"A and B are not equal\"\n",
+ " exit(0)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the Value of a 3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of b 3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "A and B are equal\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 1: Page No.: 4.112"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Prime or not\n",
+ "\n",
+ "n=input(\"Enter the Positive value of n \")\n",
+ "i=2\n",
+ "\n",
+ "#Calculation\n",
+ "while n>i:\n",
+ " if n%i==0 & i!=n:\n",
+ " #r=n%i\n",
+ " #if r==0:\n",
+ " print \"The Given value of \",n,\" is not a prime\"\n",
+ " break\n",
+ " i+=1\n",
+ "else:\n",
+ " print \"The Given Value\",n, \"is Prime\"\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Positive value of n 3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Given Value 3 is Prime\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 2: Page No.: 4.113"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Find the Greatest Common Division\n",
+ "\n",
+ "i=int(input(\"Give the Value of i \"))\n",
+ "j=int(input(\"Give the value of j \"))\n",
+ " \n",
+ "def gcd(i,j):\n",
+ " if i > j:\n",
+ " k = i%j\n",
+ " if k == 0:\n",
+ " return j\n",
+ " else:\n",
+ " return gcd(j, k)\n",
+ " if i < j:\n",
+ " i = j\n",
+ " j = i\n",
+ " return gcd(i, j)\n",
+ "print \"The value of gcd\", gcd(i,j) "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the Value of i 54\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the value of j 36\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of gcd 18\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 3: Page No.: 4.115"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to which reads in a Temperature and print the temperature in opposite scale\n",
+ "\n",
+ "\n",
+ "print \"1.Fahrenheit to Celcius\\n2.Celcius to Fahrenheit\\n\"\n",
+ "code=input(\"Choose Option to find Temperature: \")\n",
+ "\n",
+ "while code!=0:\n",
+ " if code==1:\n",
+ " f=float(input(\"Give the Value for Fahrenheit Temperature \"))\n",
+ " c=(f-32.0)*5.0/9.0\n",
+ " break\n",
+ " elif code==2:\n",
+ " c=float(input(\"Give the Value for Celcius Temperature \"))\n",
+ " f=9.0*c/5.0+32.0\n",
+ " break\n",
+ " else:\n",
+ " print \"Give proper Code Value for Temperature Calculation\"\n",
+ " break\n",
+ "print \"C=\", \"%.3f\"%float(c)\n",
+ "print \"F=\",f "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1.Fahrenheit to Celcius\n",
+ "2.Celcius to Fahrenheit\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Choose Option to find Temperature: 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give the Value for Fahrenheit Temperature 100\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "C= 37.778\n",
+ "F= 100.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 17
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter05.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter05.ipynb
new file mode 100755
index 00000000..fa4db685
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter05.ipynb
@@ -0,0 +1,987 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:8b48219cd7d973f69d80d4d491de4bdba5cb9c73135095697b1625a862f6bc97"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 05 : Defining and Processing of Arrays"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page Number: 5.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to read 5 data items from input and store them in an array and display their sum\n",
+ "\n",
+ "#Local definitions\n",
+ "a = []\n",
+ "sum = 0\n",
+ "\n",
+ "for i in range(0,5):\n",
+ " a.append(0)\n",
+ "print \"Enter 5 integer numbers\" \n",
+ "for i in range(0,5):\n",
+ " a[i] = eval(raw_input())\n",
+ " \n",
+ "for i in range(0,5): \n",
+ " sum = sum + a[i] \n",
+ " \n",
+ "print \"The sum of given numbers is : %d\\n\" %sum"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter 5 integer numbers\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "120\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "45\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "69\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "390\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "45\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The sum of given numbers is : 669\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2 Page No. 5.7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to accept 5 numbers and print whether the number is even or not\n",
+ "\n",
+ "#Local Variable\n",
+ "a=[]\n",
+ "\n",
+ "for i in range(5):\n",
+ " a.append(0)\n",
+ "for i in range(0,5):\n",
+ " i+1\n",
+ " a[i]=eval(raw_input(\"Enter the %d number: \"%(i+1))) \n",
+ " print \"\\n\"\n",
+ "for i in range (0,5):\n",
+ " if a[i]%2==0:\n",
+ " print \"%d Number is Even\"%a[i]\n",
+ " else:\n",
+ " print \"%d Number is Odd\"%a[i]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 1 number: 17\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 2 number: 38\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 3 number: 79\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 4 number: 80\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 5 number: 76\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "17 Number is Odd\n",
+ "38 Number is Even\n",
+ "79 Number is Odd\n",
+ "80 Number is Even\n",
+ "76 Number is Even\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3 Page No. 5.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to illustrate how a character array can be used.\n",
+ "\n",
+ "#Local definition\n",
+ "word=['F', 'R', 'I', 'E', 'N', 'D', 'S']\n",
+ "\n",
+ "for i in range(0,7):\n",
+ " word.append(0)\n",
+ "for i in range(0,7):\n",
+ " print word[i],"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "F R I E N D S\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page Number: 5.8"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to sort the given strings alphabetically\n",
+ "\n",
+ "b = raw_input(\"Enter the text to sort : \")\n",
+ "print \"Sorted Text are : \",''.join(sorted(b, key=lambda v: (v.upper(), v[0].islower())))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the text to sort : VRBPublishers\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sorted Text are : BbehilPRrssuV\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 5, Page Number: 5.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using two dimension array\n",
+ "\n",
+ "#Local definition \n",
+ "stud = [[0 for i in xrange(0,4)] for i in xrange(0,4)] #stud is a array name with 4 rows and 2 columns\n",
+ "\n",
+ "for i in range(0,4):\n",
+ " print \"Enter the %d Student roll no and Mark:\" %i\n",
+ " stud[i][1], stud[i][2] = input()\n",
+ " \n",
+ "for i in range(0,4):\n",
+ " print \"%d Student roll no %d mark %d\" %(i, stud[i][1], stud[i][2])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 0 Student roll no and Mark:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3977,80\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 1 Student roll no and Mark:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "17776,95\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 2 Student roll no and Mark:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6682,82\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the 3 Student roll no and Mark:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6683,85\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0 Student roll no 3977 mark 80\n",
+ "1 Student roll no 17776 mark 95\n",
+ "2 Student roll no 6682 mark 82\n",
+ "3 Student roll no 6683 mark 85\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 6, Page Number: 5.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to illustrate Matrix Multiplication\n",
+ "\n",
+ "a = [[0 for i in xrange(0,5)] for i in xrange(0,5)]\n",
+ "b = [[0 for i in xrange(0,5)] for i in xrange(0,5)]\n",
+ "c = [[0 for i in xrange(0,5)] for i in xrange(0,5)]\n",
+ "\n",
+ "while True:\n",
+ " r1, c1 = input(\"Enter the size of the matrix A....\")\n",
+ " r2, c2 = input(\"Enter the size of the matrix B....\")\n",
+ " if c1 == r2:\n",
+ " print \"Enter matrix A elements...\"\n",
+ " for i in range (0,r1):\n",
+ " for j in range (0,c1):\n",
+ " a[i][j] = input()\n",
+ " \n",
+ " print \"Enter matrix B elements...\"\n",
+ " for i in range (0,r2):\n",
+ " for j in range (0,c2):\n",
+ " b[i][j] = input()\n",
+ " \n",
+ " for i in range(0,r1):\n",
+ " for j in range(0,c1):\n",
+ " c[i][j] = 0\n",
+ " for k in range(0,c1):\n",
+ " c[i][j] += a[i][k] * b[k][j]\n",
+ " \n",
+ " print \"The resultant matrix is....\"\n",
+ " for i in range(0,r1):\n",
+ " for j in range(0,c1):\n",
+ " print \"%d\\t\" %c[i][j],\n",
+ " print \"\\n\"\n",
+ " break \n",
+ " else:\n",
+ " print \"Multiplication is not possible\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the size of the matrix A....3,3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the size of the matrix B....2,2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Multiplication is not possible\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the size of the matrix A....3,3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the size of the matrix B....3,3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter matrix A elements...\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter matrix B elements...\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The resultant matrix is....\n",
+ "18\t18\t18\t\n",
+ "\n",
+ "18\t18\t18\t\n",
+ "\n",
+ "18\t18\t18\t\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 7, Page Number: 5.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print two dimensional array by row by row\n",
+ "\n",
+ "arr = [[0 for i in xrange(0,4)] for i in xrange(0,4)]\n",
+ "\n",
+ "for i in range(0,3):\n",
+ " for j in range(0,4):\n",
+ " arr[i][j] = (i * 4) + j + 1\n",
+ " \n",
+ " \n",
+ "print \"Printing array contents :\"\n",
+ "for i in range(0,3):\n",
+ " for j in range(0,4):\n",
+ " print \"%3d\" %arr[i][j],\n",
+ " print \"\\n\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Printing array contents :\n",
+ " 1 2 3 4 \n",
+ "\n",
+ " 5 6 7 8 \n",
+ "\n",
+ " 9 10 11 12 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 8, Page Number: 5.14"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to add and display the results of 5 nos\n",
+ "\n",
+ "#Function definition \n",
+ "def add(x,ar):\n",
+ " sum = 0\n",
+ " for i in range(0,5):\n",
+ " sum += ar[i]\n",
+ " print \"Sum is ... %d\" %sum \n",
+ " \n",
+ "a = []\n",
+ "n = 5\n",
+ "for i in range(0,5):\n",
+ " a.append(0)\n",
+ "print \"Enter 5 values\"\n",
+ "for i in range(0,5):\n",
+ " a[i] = input()\n",
+ "add(n,a) #function call"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter 5 values\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "30\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "40\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "50\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sum is ... 150\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 9, Page Number: 5.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for capture and store n values into array and print them\n",
+ "\n",
+ "#Function definition \n",
+ "def arr(a = []):\n",
+ " for i in range(0,5):\n",
+ " print \"Value in array %d\\n\" %a[i]\n",
+ " \n",
+ "a = []\n",
+ "for i in range(0,5):\n",
+ " a.append(0)\n",
+ "for i in range(0,5):\n",
+ " a[i] = i\n",
+ "arr(a) #Function call"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value in array 0\n",
+ "\n",
+ "Value in array 1\n",
+ "\n",
+ "Value in array 2\n",
+ "\n",
+ "Value in array 3\n",
+ "\n",
+ "Value in array 4\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 10, Page Number: 5.16"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print the character string from the array\n",
+ "\n",
+ "name = \"LAK\"\n",
+ "print \"%s\" %name"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "LAK\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 11, Page Number: 5.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for explaining the working of 4 dimensional array\n",
+ "\n",
+ "#Local definition\n",
+ "array_4d = [[[[0 for i in xrange(0,3)] for i in xrange(0,3)]for i in xrange(0,3)] for i in xrange(0,3)]\n",
+ "\n",
+ "#looping statements \n",
+ "for a in range(0,3):\n",
+ " for b in range(0,3):\n",
+ " for c in range(0,3):\n",
+ " for d in range(0,3):\n",
+ " array_4d[a][b][c][d] = a + b + c + d\n",
+ "#Result \n",
+ "for a in range(0,3) :\n",
+ " print \"\\n\"\n",
+ " for b in range(0,3):\n",
+ " for c in range(0,3):\n",
+ " for d in range(0,3):\n",
+ " print \"%3d\" %array_4d[a][b][c][d],\n",
+ " print \"\\n\" "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ " 0 1 2 \n",
+ "\n",
+ " 1 2 3 \n",
+ "\n",
+ " 2 3 4 \n",
+ "\n",
+ " 1 2 3 \n",
+ "\n",
+ " 2 3 4 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 2 3 4 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 4 5 6 \n",
+ "\n",
+ "\n",
+ "\n",
+ " 1 2 3 \n",
+ "\n",
+ " 2 3 4 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 2 3 4 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 4 5 6 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 4 5 6 \n",
+ "\n",
+ " 5 6 7 \n",
+ "\n",
+ "\n",
+ "\n",
+ " 2 3 4 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 4 5 6 \n",
+ "\n",
+ " 3 4 5 \n",
+ "\n",
+ " 4 5 6 \n",
+ "\n",
+ " 5 6 7 \n",
+ "\n",
+ " 4 5 6 \n",
+ "\n",
+ " 5 6 7 \n",
+ "\n",
+ " 6 7 8 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter06.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter06.ipynb
new file mode 100755
index 00000000..09f324b0
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter06.ipynb
@@ -0,0 +1,1424 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:d7231c68ebf3352357e97f096d7bb05469f2e0aae52fa150a1a57a7e75ef01fb"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 06 : Handling Of Character Strings"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page Number: 5.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for reading a line of text\n",
+ "\n",
+ "n = 0\n",
+ "print \"Enter text press RETRUN to end\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter text press RETRUN to end\n"
+ ]
+ }
+ ],
+ "prompt_number": 48
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page Number: 5.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#String function\n",
+ "\n",
+ "s1= \"Hello\"\n",
+ "s2='H''e''l''l''o'\n",
+ "\n",
+ "print s1\n",
+ "print s2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Hello\n",
+ "Hello\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page Number: 5.22"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using strlen() function\n",
+ "\n",
+ "name = \"MUNI\"\n",
+ "len1 = len(name)\n",
+ "len2 = len(\"LAK\")\n",
+ "print \"String length of %s is %d\" %(name,len1)\n",
+ "print \"String length of %s is %d\" %(\"LAK\",len2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String length of MUNI is 4\n",
+ "String length of LAK is 3\n"
+ ]
+ }
+ ],
+ "prompt_number": 50
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page Number: 5.23"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using strcpy() function\n",
+ "def strcpy(cstring1):\n",
+ " import copy\n",
+ " cstring2=copy.copy(cstring1)\n",
+ " return cstring2 \n",
+ "\n",
+ "source = \"MUNI\"\n",
+ "target = strcpy(source)\n",
+ "print \"Source string is %s\" %source\n",
+ "print \"Target string is %s\" %target"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Source string is MUNI\n",
+ "Target string is MUNI\n"
+ ]
+ }
+ ],
+ "prompt_number": 64
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 5, Page Number:5.24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Strcat function\n",
+ "\n",
+ "str1=\"MUNI\"\n",
+ "str2=\"LAK\"\n",
+ "print str1+str2\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "MUNILAK\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 6, Page Number: 5.24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using strcat() function\n",
+ "def strcat(cstring1, cstring2):\n",
+ " cstring3 = cstring1 + cstring2\n",
+ " return cstring3\n",
+ "\n",
+ "source = \"Ramesh\"\n",
+ "target = \"Babu\"\n",
+ "source = strcat(source,target)\n",
+ "print \"Source string is %s\" %source\n",
+ "print \"Target string is %s\" %target"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Source string is RameshBabu\n",
+ "Target string is Babu\n"
+ ]
+ }
+ ],
+ "prompt_number": 69
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 7, Page Number: 5.25"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using strcmp() function\n",
+ "\n",
+ "name = \"Kalai\"\n",
+ "name1 = \"Malai\"\n",
+ "if name ==\"Kalai\":\n",
+ " print \"0\",\n",
+ "if name1!=name:\n",
+ " print \"1\",\n",
+ "if name != \"Kalai mani\":\n",
+ " print \"6\"\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "0 1 6\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 8, Page Number: 5.26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using strrev() function\n",
+ "def strrev(cstring1):\n",
+ " cstring2 = ' '\n",
+ " for i in range(len(cstring1)-1,-1,-1):\n",
+ " cstring2 = cstring2 + cstring1[i]\n",
+ " return cstring2\n",
+ "\n",
+ "y = raw_input(\"Enter the string \")\n",
+ "print \"The string reversed is : %s\" %strrev(y)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the string book\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The string reversed is : koob\n"
+ ]
+ }
+ ],
+ "prompt_number": 85
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 9, Page Number: 5.27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using enumerated data type\n",
+ "def enum(*sequential, **named):\n",
+ " enums = dict(zip(sequential, range(len(sequential))), **named)\n",
+ " return type('Enum', (), enums)\n",
+ "\n",
+ "week = enum(' ', 'sun','Mon','Tue','Wed','Thr','Fri','Sat')\n",
+ "print \"Mon = %d\" %week.Mon\n",
+ "print \"Tue = %d\" %week.Tue\n",
+ "print \"Wed= %d\" %week.Wed\n",
+ "print \"Sat = %d\" %week.Sat"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Mon = 2\n",
+ "Tue = 3\n",
+ "Wed= 4\n",
+ "Sat = 7\n"
+ ]
+ }
+ ],
+ "prompt_number": 125
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 10, Page Number: 5.28"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to identify whether the entered character is letter, digit or other symbols\n",
+ "def enum(*sequential, **named):\n",
+ " enums = dict(zip(sequential, range(len(sequential))), **named)\n",
+ " return type('Enum', (), enums)\n",
+ "\n",
+ "ctype = enum(' ', 'Letter', 'Digit', 'Other')\n",
+ "ch = raw_input(\"Enter a any character.\")\n",
+ "a = ch.isalpha()\n",
+ "if a != False:\n",
+ " print \"%c is %d type of symbol.\" %(ch,ctype.Letter)\n",
+ "else:\n",
+ " a = ch.isdigit()\n",
+ " if a != False:\n",
+ " print \"%c is %d type of symbol.\" %(ch,ctype.Digit)\n",
+ " else:\n",
+ " print \"%c is %d type of symbol.\" %(ch,ctype.Other)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a any character.%\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "% is 3 type of symbol.\n"
+ ]
+ }
+ ],
+ "prompt_number": 143
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 1, Page Number: 5.29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for sorting an array of elements\n",
+ "\n",
+ "a = []\n",
+ "n = input(\"Enter Upper limit....\")\n",
+ "for i in range(0,n):\n",
+ " a.append(0)\n",
+ "print \"Enter elements....\" \n",
+ "for i in range(0,n):\n",
+ " a[i]=input()\n",
+ "for i in range(0,n):\n",
+ " for j in range(i,n):\n",
+ " if a[i]>a[j]:\n",
+ " t = a[i]\n",
+ " a[i] = a[j]\n",
+ " a[j] = t\n",
+ "print \"Numbers in Ascending order\"\n",
+ "for i in range(0,n):\n",
+ " print \"%d\" %a[i],"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Upper limit....6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter elements....\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Numbers in Ascending order\n",
+ "1 2 3 4 5 6\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 2, Page Number: 5.31"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to fing Median for a given 'n' numbers\n",
+ "\n",
+ "arr = []\n",
+ "n = input(\"Enter Upper limit....\")\n",
+ "for i in range(0,n):\n",
+ " arr.append(0)\n",
+ "print \"Enter..%d..values\" %n \n",
+ "for i in range(0,n):\n",
+ " arr[i]=input()\n",
+ "for i in range(1,n):\n",
+ " for j in range(1,n-i):\n",
+ " if arr[j] <= arr[j+1]:\n",
+ " t = arr[j]\n",
+ " arr[j] = arr[j+1]\n",
+ " arr[j+1] = t\n",
+ " else:\n",
+ " continue\n",
+ "if n%2 == 0:\n",
+ " median = (arr[n/2]+arr[n/2+1])/2.0\n",
+ "else:\n",
+ " median = arr[n/2+1]\n",
+ "print \"Median is....%.f\" %median \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Upper limit....3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter..3..values\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "30\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Median is....20\n"
+ ]
+ }
+ ],
+ "prompt_number": 162
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 3, Page Number: 5.32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to find standard deviation for the given data\n",
+ "import math\n",
+ "\n",
+ "val = []\n",
+ "sum = ssqr = n = 0\n",
+ "for i in range(0,100):\n",
+ " val.append(0)\n",
+ "print \"Enter Values -999 to stop....\"\n",
+ "for i in range(0,100):\n",
+ " val[i] = float(raw_input())\n",
+ " if val[i] == -999:\n",
+ " break\n",
+ " sum = float(sum) + val[i] \n",
+ " n = n + 1\n",
+ "mean = float(sum) / float(n) \n",
+ "for i in range(0,n):\n",
+ " dev = val[i] - mean\n",
+ " ssqr = float(ssqr) + float(dev)*float(dev)\n",
+ "var = ssqr / float(n) \n",
+ "sd = math.sqrt(float(var))\n",
+ "print \"Number of Items.....%d\" %n\n",
+ "print \"Mean is .....%f\" %mean\n",
+ "print \"Standard Deviation is .....%f\" %sd"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Values -999 to stop....\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "20\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "30\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "40\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "50\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-999\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number of Items.....5\n",
+ "Mean is .....30.000000\n",
+ "Standard Deviation is .....14.142136\n"
+ ]
+ }
+ ],
+ "prompt_number": 169
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 4, Page Number: 5.34"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Bubble sort using function\n",
+ "\n",
+ "def bubble(n, x = []):\n",
+ " for item in range(0,n-1):\n",
+ " for i in range(item+1,n):\n",
+ " if x[i]<x[item]:\n",
+ " temp = x[item]\n",
+ " x[item] = x[i]\n",
+ " x[i] = temp\n",
+ " \n",
+ "a = [] \n",
+ "n = input(\"Enter upper limit: \")\n",
+ "for i in range(0,n):\n",
+ " a.append(0)\n",
+ "for i in range(0,n):\n",
+ " a[i] = input()\n",
+ " \n",
+ "bubble(n,a) \n",
+ "print \"After sorting\",\n",
+ "for i in range(0,n):\n",
+ " print \"%d\" %a[i],"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter upper limit: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "After sorting 1 2 3 4 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 174
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 5, Page Number: 5.35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to sort an element using Insertion sort\n",
+ "\n",
+ "a = []\n",
+ "x = input(\"Elements to be inserted \")\n",
+ "for i in range(0,100):\n",
+ " a.append(0)\n",
+ "i = 0\n",
+ "while x != -99:\n",
+ " k = i-1\n",
+ " while (x<a[k]) and (k>=0):\n",
+ " a[k+1] = a[k]\n",
+ " k = k-1\n",
+ " a[k+1]=x\n",
+ " print \"Array after inserting %d:\" %x\n",
+ " for j in range(0,i):\n",
+ " print \"%5d\" %a[j]\n",
+ " x = input(\"Elements to be inserted(-99 to stop)?\")\n",
+ " i = i+1\n",
+ "print \"The final sorted array\"\n",
+ "for j in range(0,i):\n",
+ " print \"%5d\" %a[j],"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Elements to be inserted 5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Array after inserting 5:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Elements to be inserted(-99 to stop)?3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Array after inserting 3:\n",
+ " 3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Elements to be inserted(-99 to stop)?4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Array after inserting 4:\n",
+ " 3\n",
+ " 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Elements to be inserted(-99 to stop)?2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Array after inserting 2:\n",
+ " 2\n",
+ " 3\n",
+ " 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Elements to be inserted(-99 to stop)?1\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Array after inserting 1:\n",
+ " 1\n",
+ " 2\n",
+ " 3\n",
+ " 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Elements to be inserted(-99 to stop)?-99\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The final sorted array\n",
+ " 1 2 3 4 5\n"
+ ]
+ }
+ ],
+ "prompt_number": 186
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 6, Page Number: 5.36"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to sort an element using selection sort\n",
+ "\n",
+ "a = []\n",
+ "for i in range(0,100):\n",
+ " a.append(0)\n",
+ "n = input(\"Enter Number of elements in array...\")\n",
+ "print \"Enter Elements...\",n\n",
+ "for i in range(0,n):\n",
+ " a[i] = input()\n",
+ "for i in range(0,n-1):\n",
+ " m = i\n",
+ " for j in range(i+1,n):\n",
+ " if a[m]>a[j]:\n",
+ " m = j\n",
+ " if i != m:\n",
+ " k = a[i]\n",
+ " a[i] = a[m]\n",
+ " a[m] = k\n",
+ " \n",
+ "print \"Sorted Array (Selection Sort) is...\\n\"\n",
+ "for i in range(0,n):\n",
+ " print \"%5d\" %a[i],"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Number of elements in array...9\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Elements... 9\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "56\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "326\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "85\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "42\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "156\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "845\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "66\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "55\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sorted Array (Selection Sort) is...\n",
+ "\n",
+ " 1 42 55 56 66 85 156 326 845\n"
+ ]
+ }
+ ],
+ "prompt_number": 190
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 7, Page Number: 5.38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Quick sort\n",
+ "\n",
+ "def quickSort(array):\n",
+ " quickSortHelper(array,0,len(array)-1)\n",
+ "\n",
+ "def quickSortHelper(array,right,left):\n",
+ " if right<left:\n",
+ " splitpoint = partition(array,right,left)\n",
+ " quickSortHelper(array,right,splitpoint-1)\n",
+ " quickSortHelper(array,splitpoint+1,left)\n",
+ "\n",
+ "def partition(array,right,left):\n",
+ " pivotvalue = array[right]\n",
+ "\n",
+ " begin = right+1\n",
+ " end = left\n",
+ "\n",
+ " done = False\n",
+ " while not done:\n",
+ "\n",
+ " while begin <= end and \\\n",
+ " array[begin] <= pivotvalue:\n",
+ " begin = begin + 1\n",
+ "\n",
+ " while array[end] >= pivotvalue and \\\n",
+ " end >= begin:\n",
+ " end = end -1\n",
+ "\n",
+ " if end < begin:\n",
+ " done = True\n",
+ " else:\n",
+ " temp = array[begin]\n",
+ " alist[begin] = array[end]\n",
+ " alist[end] = temp\n",
+ "\n",
+ " temp = array[right]\n",
+ " array[right] = array[end]\n",
+ " array[end] = temp\n",
+ " return end\n",
+ "\n",
+ "array = []\n",
+ "n=input(\"Enter the values in array: \")\n",
+ "for i in range (0,n):\n",
+ " array.append(0)\n",
+ "for i in range (0,n):\n",
+ " array[i]=input()\n",
+ " \n",
+ "quickSort(array)\n",
+ "print \"Quick Sorted Array is\", array"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the values in array: 5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Quick Sorted Array is [1, 2, 3, 4, 5]\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 8, Page Number: 5.40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#program to find the specified elements from the array using linear searching\n",
+ "\n",
+ "a = [100]\n",
+ "for i in range(0,100):\n",
+ " a.append(0)\n",
+ "c = 'y'\n",
+ "while (c=='y')or(c=='Y'):\n",
+ " no = input(\"Enter the size of sorting\")\n",
+ " print \"Enter the elements of the array\"\n",
+ " for i in range(0,no):\n",
+ " a[i]=input()\n",
+ " k = input(\"Enter the element to be searched\") \n",
+ " for i in range(0,no):\n",
+ " if k == a[i]:\n",
+ " print \"Element %d is in the position %d\" %(k,i+1)\n",
+ " f=2\n",
+ " break\n",
+ " if f==1:\n",
+ " print \"The entered element is not in the array\"\n",
+ " ch = raw_input(\"If you want to continue y/n \")\n",
+ " c = ch\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the size of sorting5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements of the array\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the element to be searched4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Element 4 is in the position 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "If you want to continue y/n n\n"
+ ]
+ }
+ ],
+ "prompt_number": 206
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 9, Page Number: 5.42"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to find the specified element from array using Binary search\n",
+ "\n",
+ "a = [100]\n",
+ "for i in range(0,100):\n",
+ " a.append(0)\n",
+ "no = input(\"Enter the size of sorting\")\n",
+ "print \"Enter the elements in ascending order\"\n",
+ "for i in range(0,no):\n",
+ " a[i]=input() \n",
+ "t = input(\"Enter the element to be searched\") \n",
+ "l=0\n",
+ "h=no-1\n",
+ "while l <= h:\n",
+ " m = (l+h)/2\n",
+ " if t<a[m]:\n",
+ " h = m-1\n",
+ " elif t>a[m]:\n",
+ " l = m+1\n",
+ " else:\n",
+ " print \"Entered %d is in position %d\" %(t,m+1)\n",
+ " f=2\n",
+ " break\n",
+ "if f==1:\n",
+ " print \"Entered element is not in the array\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the size of sorting5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements in ascending order\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the element to be searched3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Entered 3 is in position 2\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter07.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter07.ipynb
new file mode 100755
index 00000000..ee25427a
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter07.ipynb
@@ -0,0 +1,254 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:59d989e4d68b99137fb5255fe771e42a62c5ce35100304584930ea0c003ea2ac"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 07 : User Defined Functions"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, page no.5.49"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate Local and Global Declaration \n",
+ "\n",
+ "#variable declaration globally\n",
+ "i=0 \n",
+ "print \"Value of i in main\", i\n",
+ "\n",
+ " #define function\n",
+ "def f1(): \n",
+ " k=0\n",
+ " i=50\n",
+ " print \"Value of i after function call\",i\n",
+ " \n",
+ "#Function Call\n",
+ "f1() \n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value of i in main 0\n",
+ "Value of i after function call 50\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, page no: 5.50"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate usage of local and global variable\n",
+ "\n",
+ "for i in range(0,3):\n",
+ " print \"Value of i is:\", i\n",
+ " \n",
+ "i=590\n",
+ "print \"The Value of i is:\", i \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Value of i is: 0\n",
+ "Value of i is: 1\n",
+ "Value of i is: 2\n",
+ "The Value of i is: 590\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page no.5.52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to call function without parameters\n",
+ "def message():\n",
+ " print \"Main Message\"\n",
+ " \n",
+ "print \"Function Message\"\n",
+ "\n",
+ "message()\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Function Message\n",
+ "Main Message\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page No.5.52"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to call function with parameter\n",
+ "\n",
+ "#Defining function\n",
+ "def add(x,y):\n",
+ " z=0\n",
+ " z=x+y\n",
+ " return z\n",
+ "\n",
+ "k=add(10,20)\n",
+ "\n",
+ "#Result\n",
+ "print \"The Value of k is \", k"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Value of k is 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 25
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 5, page no.5.53"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to write prototype of the function\n",
+ "\n",
+ "k=0\n",
+ "\n",
+ "#Defining in function\n",
+ "def f1(k):\n",
+ " k=k+100\n",
+ " return k\n",
+ "\n",
+ "#Result\n",
+ "print \"The value of i before call: \", k\n",
+ "\n",
+ "print \"The Value of i after call: \",(f1(k))\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The value of i before call: 0\n",
+ "The Value of i after call: 100\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 6, page no. 5.54"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to write prototype definition in main function\n",
+ "\n",
+ "def fun(k):\n",
+ " k=k+10\n",
+ " return k\n",
+ "\n",
+ "i=0\n",
+ "\n",
+ "#Result\n",
+ "print \"The i value before call %d\\n\"%(i)\n",
+ "print \"The i value after call %d\\n\"%fun(i)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The i value before call 0\n",
+ "\n",
+ "The i value after call 10\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb
new file mode 100755
index 00000000..e40c1b43
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter08.ipynb
@@ -0,0 +1,420 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:5d85b398d61f498d1deba465b9747c5d15996be1754212b25012ca792b193a16"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 08 : Function Prototypes"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Function with no arguments and no return values"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.: 5.55"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to addition of two numbers\n",
+ "\n",
+ "def add():\n",
+ " a,b=input(\"Enter two numbers.. \")\n",
+ " c=a+b\n",
+ " print \"Sum is ... %d\"%(c)\n",
+ " \n",
+ "add() \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": [
+ "Sum is ... 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.:5.56"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print addition, subtraction and multiplication values\n",
+ "\n",
+ "def add():\n",
+ " a=10\n",
+ " b=5\n",
+ " print \"The Addition of given value: \",a+b\n",
+ " \n",
+ "def sub():\n",
+ " a=10\n",
+ " b=5\n",
+ " print \"The Subtraction of given value:\",a-b\n",
+ " \n",
+ "def mul():\n",
+ " a=10\n",
+ " b=5\n",
+ " print \"The Multiplication of given value:\",a*b\n",
+ " \n",
+ " \n",
+ "add()\n",
+ "sub()\n",
+ "mul()\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Addition of given value: 15\n",
+ "The Subtraction of given value: 5\n",
+ "The Multiplication of given value: 50\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Function with arguments and no return values"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, page No. 5.57"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Program for addition of two numbers\n",
+ "\n",
+ "def add(x,y):\n",
+ " z= x+y\n",
+ " print \"Sum is:\", z\n",
+ "\n",
+ "#Main Function\n",
+ "a, b = input(\"Enter two Values: \")\n",
+ " \n",
+ "add(a,b)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter two Values: 10,20\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sum is: 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ " Example: 2, page no. 5.58"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "def date(x,y,z):\n",
+ " print \"Employee Joined date is:%d/%d/%d\" %(x,y,z)\n",
+ " \n",
+ "print \"Enter the employee joining date.\"\n",
+ "\n",
+ "dd,mm,yy=eval(raw_input(\"Enter date, month, year: \"))\n",
+ "\n",
+ "date(dd,mm,yy)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the employee joining date.\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter date, month, year: 11,12,1981\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Employee Joined date is:11/12/1981\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Function with arguments and with return value"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, page no.5.59"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for addition of two numbers\n",
+ "\n",
+ "def add(x,y):\n",
+ " z=0\n",
+ " z=x+y\n",
+ " return z\n",
+ "\n",
+ "#Main Function\n",
+ "a,b=input(\"Enter the a and b value:\")\n",
+ "c=add(a,b)\n",
+ "print \"Result is:\",c"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the a and b value:10,20\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Result is: 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.:5.60"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to send and receives the values from function\n",
+ "\n",
+ "def mul(m,n):\n",
+ " return (m*n)\n",
+ "\n",
+ "m=n=sum=0\n",
+ "m,n=input(\"Enter two values:\")\n",
+ "sum=mul(m,n)\n",
+ "\n",
+ "print \"Multiplication of the entered Values:\",sum"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter two values:30,4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Multiplication of the entered Values: 120\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Function with no arguments and with return value"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, PageNo.:5.61"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for addition of two numbers\n",
+ "\n",
+ "def add():\n",
+ " a=b=c=0\n",
+ " a,b=input(\"Enter the Values of a and b:\")\n",
+ " c=a+b\n",
+ " return(c)\n",
+ "\n",
+ "c=add()\n",
+ "print \"The Output of given Values:\",c\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Values of a and b:10,20\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Output of given Values: 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No. 5.62"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to multiply three numbers using function\n",
+ "\n",
+ "\n",
+ "def mul():\n",
+ " a,b,c=input(\"Enter the three values for Multiplication: \")\n",
+ " i=a*b*c\n",
+ " return(i)\n",
+ "\n",
+ "s=mul()\n",
+ "print \"Multiplication of three numbers is= \",s\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the three values for Multiplication: 4,8,2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Multiplication of three numbers is= 64\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter09.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter09.ipynb
new file mode 100755
index 00000000..11735b92
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter09.ipynb
@@ -0,0 +1,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": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter10.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter10.ipynb
new file mode 100755
index 00000000..1a017d08
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter10.ipynb
@@ -0,0 +1,372 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:ea85b38c0942e3b3d3a1243525badd8ffa28ac492392c6aef6c8ea5823294150"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 10 : Recursion"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.: 5.67"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Factorial of an integer number.\n",
+ "\n",
+ "def rec(x):\n",
+ " f=0\n",
+ " if x==1:\n",
+ " return (1)\n",
+ " else:\n",
+ " f=x*rec(x-1)\n",
+ " return(f)\n",
+ "\n",
+ "a=input(\"Enter the number:\")\n",
+ "print \"The Factorial value of %d:\"%a,rec(a)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number:5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Factorial value of 5: 120\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.:5.67"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to read characters and print reversely using recursion.\n",
+ "\n",
+ "def reverse(c):\n",
+ " if len(c)<=0:\n",
+ " return c\n",
+ " return reverse(c[1:])+c[0]\n",
+ "\n",
+ "c=raw_input(\"Enter the Line of Text...\")\n",
+ "print reverse(c)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Line of Text...munilak\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "kalinum\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No.:5.68"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#concept of recursion\n",
+ "\n",
+ "def add(pk, pm):\n",
+ " if pm==0:\n",
+ " return pk\n",
+ " else:\n",
+ " return(1+add(pk,pm-1))\n",
+ " \n",
+ " \n",
+ "k=70\n",
+ "m=20\n",
+ "\n",
+ "i=add(k,m)\n",
+ "\n",
+ "print \"The Value of addition is %d\"%i\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Value of addition is 90\n"
+ ]
+ }
+ ],
+ "prompt_number": 37
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page No:5.70"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Tower of honoi\n",
+ "n=int(raw_input(\"How many Disks ...\\n\"))\n",
+ "\n",
+ "def honoi(n,fro,to,t):\n",
+ " if(n>0):\n",
+ " honoi(n-1,fro,t,to)\n",
+ " print \"Move disk %d from %c to %c\\n\"%(n,fro,to)\n",
+ " honoi(n-1,t,to,fro)\n",
+ " \n",
+ "fro='L'\n",
+ "to='R'\n",
+ "t='C'\n",
+ " \n",
+ "honoi(n,fro,to,t)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "How many Disks ...\n",
+ "3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Move disk 1 from L to R\n",
+ "\n",
+ "Move disk 2 from L to C\n",
+ "\n",
+ "Move disk 1 from R to C\n",
+ "\n",
+ "Move disk 3 from L to R\n",
+ "\n",
+ "Move disk 1 from C to L\n",
+ "\n",
+ "Move disk 2 from C to R\n",
+ "\n",
+ "Move disk 1 from L to R\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 1, Page No. : 5.76"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#user defined function that computes 'x' raised to the power 'y'\n",
+ "\n",
+ "import math \n",
+ "\n",
+ "x,y=input(\"Enter the Values of X and Y \")\n",
+ "\n",
+ "print \"%d to the power of %d is ... \"%(x,y),math.pow(x,y)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Values of X and Y 10,2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "10 to the power of 2 is ... 100.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 2, page No.5.76"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#nesting of function\n",
+ "\n",
+ "def ratio(x,y,z):\n",
+ " \n",
+ " def diff(m,n):\n",
+ " if(m!=n):\n",
+ " return(1)\n",
+ " else:\n",
+ " return(0)\n",
+ " \n",
+ " diff(y,z)\n",
+ " if diff(y,z):\n",
+ " return(x/(y-z))\n",
+ " else:\n",
+ " return(0)\n",
+ " \n",
+ " \n",
+ "x,y,z=input(\"Enter the values of X,Y,Z: \")\n",
+ "\n",
+ " \n",
+ "print \"Ratio is..%f\\n\"%ratio(x,y,z)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the values of X,Y,Z: 10,10,5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Ratio is..2.000000\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 3, Page No. 5.78"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Demonstration of Global Variable\n",
+ "\n",
+ "a=39 #Global Variable\n",
+ "print \"A... %d\\n\"%a\n",
+ "\n",
+ "def f1():\n",
+ " global a\n",
+ " a=a+10\n",
+ " return a\n",
+ "\n",
+ "def f2():\n",
+ " global a\n",
+ " a=a+20\n",
+ " return a\n",
+ "\n",
+ "def f3():\n",
+ " global a\n",
+ " a=a+30\n",
+ " return a\n",
+ "\n",
+ "\n",
+ "\n",
+ "print \"A...%d\\n\"%f1()\n",
+ "print \"A...%d\\n\"%f2()\n",
+ "print \"A...%d\\n\"%f3()\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "A... 39\n",
+ "\n",
+ "A...49\n",
+ "\n",
+ "A...69\n",
+ "\n",
+ "A...99\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 39
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter11.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter11.ipynb
new file mode 100755
index 00000000..0e00f235
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter11.ipynb
@@ -0,0 +1,304 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:03a9be4b5720a51a42be3ae01bfa08ccecef76e9a5e17f613e76c0afaff965de"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 11 : Structures"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.: 5.81"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Print the student number, name and marks through accessing structure elements.\n",
+ "\n",
+ "#Defining Structure in class\n",
+ "class std:\n",
+ " no=0\n",
+ " name = ''\n",
+ " m1 = m2 = m3 =0\n",
+ "\n",
+ "#assigning variable to structure class \n",
+ "s=std()\n",
+ "\n",
+ "#UserInput\n",
+ "s.no=raw_input(\"Give Student Number: \")\n",
+ "s.name=raw_input(\"Enter the Student Name: \")\n",
+ "s.m1=input(\"Enter Student Mark1: \")\n",
+ "s.m2=input(\"Enter Student Mark2: \")\n",
+ "s.m3=input(\"Enter Student Mark3: \")\n",
+ "\n",
+ "total=avg=0.0\n",
+ "\n",
+ "total = (s.m1 + s.m2 + s.m3)\n",
+ "avg='%.2f' %(total / 3)\n",
+ "\n",
+ "#Result\n",
+ "print \"\\nThe Output is.... \\n\",s.no,s.name,total,avg"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give Student Number: 1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student Name: raja\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark1: 99\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark2: 97\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark3: 95\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "The Output is.... \n",
+ "1 raja 291 97.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 39
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No. 5.83"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#print a value from Structure.\n",
+ "\n",
+ "class struct:\n",
+ " a=b=0\n",
+ " \n",
+ "x=struct()\n",
+ "y=struct()\n",
+ "\n",
+ "x.a=29\n",
+ "y=x\n",
+ "\n",
+ "#Result\n",
+ "print \"The Value of a %d\"%y.a\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Value of a 29\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No.:5.84"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program for User defined data type \n",
+ "\n",
+ "#There is no preprocessor directive in python\n",
+ "D = 7\n",
+ "\n",
+ "#No typedef function in python\n",
+ "wk = int(raw_input(\"Enter Weeks : \"))\n",
+ "\n",
+ "#Result\n",
+ "print \"\\nNumber of Days = %d\"%(wk*D)\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Weeks : 4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Number of Days = 28\n"
+ ]
+ }
+ ],
+ "prompt_number": 55
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page.No.:5.85"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to create user defined data type from structure\n",
+ "\n",
+ "\n",
+ "class struct:\n",
+ " name=''\n",
+ " sex=''\n",
+ " age=0\n",
+ " \n",
+ "\n",
+ "\n",
+ "candidate = [struct() for i in range(0,2)]\n",
+ "\n",
+ "for a in range(0,2):\n",
+ " candidate[a].name= raw_input(\"Name of the Employee: \")\n",
+ " candidate[a].sex= raw_input(\"Sex: \")\n",
+ " candidate[a].age= input(\"Age: \")\n",
+ "\n",
+ "#Result\n",
+ "print \"\\n Name\\t Sex\\t Age\\n\"\n",
+ "\n",
+ "for a in range(0,2):\n",
+ " print \" %s\\t\"%(candidate[a].name),\" %s\\t\"%(candidate[a].sex),\" %d\\n\"%(candidate[a].age)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Name of the Employee: venkat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sex: m\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Age: 25\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Name of the Employee: geetha\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sex: f\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Age: 23\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " Name\t Sex\t Age\n",
+ "\n",
+ " venkat\t m\t 25\n",
+ "\n",
+ " geetha\t f\t 23\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 68
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter12.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter12.ipynb
new file mode 100755
index 00000000..54918fbb
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter12.ipynb
@@ -0,0 +1,829 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:13c473411b35212c9727620c7673dc52636d4bf1a83b0d4eeb082d160a75324d"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 12 : Union"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.5.87"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#program using union.\n",
+ "\n",
+ "class union_name:\n",
+ " a=0\n",
+ " b=[0,1]\n",
+ " \n",
+ "c=union_name()\n",
+ "c.a=256\n",
+ "\n",
+ "print \"c.a value is %d\\n \"%c.a\n",
+ "print \"c.b[0] value is %d\\n\"%c.b[0]\n",
+ "print \"c.b[1] value is %d\\n\"%c.b[1]\n",
+ "\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "c.a value is 256\n",
+ " \n",
+ "c.b[0] value is 0\n",
+ "\n",
+ "c.b[1] value is 1\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.:5.87"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#program to find size of union and number of bytes\n",
+ "\n",
+ "import sys\n",
+ "\n",
+ "class union_result:\n",
+ " marks=0\n",
+ " grade=''\n",
+ " \n",
+ " \n",
+ "class struct_res:\n",
+ " name=[15]\n",
+ " age=0\n",
+ " sex=''\n",
+ " address=''\n",
+ " pincode=0\n",
+ " perf=union_result()\n",
+ " \n",
+ "data=struct_res() \n",
+ "\n",
+ "#Result\n",
+ "print \"Size of Union: %d\\n\"%sys.getsizeof(data.perf)\n",
+ "print \"Size of Structure: %d\\n\"%sys.getsizeof(data)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Size of Union: 32\n",
+ "\n",
+ "Size of Structure: 32\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Pointer to Unions cannot convert as no pointer in python. Page no. 5.88"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": []
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No.:5.89"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program that includes of initial values to structure variable\n",
+ "\n",
+ "import sys\n",
+ "\n",
+ "\n",
+ "class union_id:\n",
+ " color='20'\n",
+ " size=0\n",
+ " \n",
+ "\n",
+ "class struct_clothes:\n",
+ " manufacturer='30'\n",
+ " cost=0.0\n",
+ " description=union_id()\n",
+ " \n",
+ " \n",
+ "shirt=struct_clothes()\n",
+ "shirt.manufacturer='Indian'\n",
+ "shirt.cost=35.00\n",
+ "shirt.description.color='Black'\n",
+ "\n",
+ "print \"%d\\n\"%(sys.getsizeof(union_id))\n",
+ "\n",
+ "print \"%s %f \"%(shirt.manufacturer,shirt.cost),\"%s %d\\n \"%(shirt.description.color, shirt.description.size)\n",
+ " \n",
+ "\n",
+ "shirt.description.size =12\n",
+ "\n",
+ "\n",
+ "print \"%s %f \"%(shirt.manufacturer, shirt.cost),\"%s %d\\n \"%(shirt.description.color, shirt.description.size)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "48\n",
+ "\n",
+ "Indian 35.000000 Black 0\n",
+ " \n",
+ "Indian 35.000000 Black 12\n",
+ " \n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page no.: 5.92"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to read and write employee and their date of joining using nested structure. \n",
+ "\n",
+ "\n",
+ "class date:\n",
+ " day=0\n",
+ " month=\"\"\n",
+ " year=0\n",
+ " \n",
+ "class employee:\n",
+ " code=0\n",
+ " name=''\n",
+ " salary=0.0\n",
+ " doj=date()\n",
+ " \n",
+ " \n",
+ "emp1=employee()\n",
+ "\n",
+ "emp1.code=input(\"Enter Employee Code: \")\n",
+ "emp1.name=raw_input(\"Enter the Employee Name: \")\n",
+ "emp1.salary=input(\"Enter the Employee Salary: \")\n",
+ "\n",
+ "print \"\\nEnter Date of joining in order\\n\"\n",
+ "emp1.doj.day=input(\"Enter day: \")\n",
+ "emp1.doj.month=raw_input(\"Enter month: \")\n",
+ "emp1.doj.year=input(\"Enter year: \")\n",
+ "\n",
+ "print \"\\nThe Employee Code is: %d\"%emp1.code\n",
+ "print \"\\nThe Employee Name is: %s\"%emp1.name\n",
+ "print \"\\nThe Employee Name is: %f\"%emp1.salary\n",
+ "print \"\\nThe Employee DOJ is: %d %s %d\"%(emp1.doj.day,emp1.doj.month,emp1.doj.year)\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Employee Code: 200\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Employee Name: VIJI\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Employee Salary: 2000.00\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Enter Date of joining in order\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter day: 12\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter month: December\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter year: 2004\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "The Employee Code is: 200\n",
+ "\n",
+ "The Employee Name is: VIJI\n",
+ "\n",
+ "The Employee Name is: 2000.000000\n",
+ "\n",
+ "The Employee DOJ is: 12 December 2004\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 5, Page No. 5.93"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to store 3 records in one structure\n",
+ "\n",
+ "\n",
+ "class book:\n",
+ " name=''\n",
+ " price=0\n",
+ " pages=0\n",
+ " \n",
+ " \n",
+ "b=[book() for a in range(0,3)]\n",
+ "\n",
+ "for i in range(0,3):\n",
+ " b[i].name=raw_input(\"Enter the Book Name: \")\n",
+ " b[i].price=input(\"Enter the Book Price: \")\n",
+ " b[i].pages=input(\"Enter the Book Pages: \")\n",
+ " \n",
+ "print '\\n' \n",
+ "for i in range(0,3):\n",
+ " print \"%s\\t\"%(b[i].name),\"%d\\t\"%(b[i].price),\"%d\\n\"%(b[i].pages)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Name: English\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Price: 165\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Pages: 200\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Name: Maths\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Price: 300\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Pages: 450\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Name: Physics\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Price: 250\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book Pages: 370\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "English\t165\t200\n",
+ "\n",
+ "Maths\t300\t450\n",
+ "\n",
+ "Physics\t250\t370\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 6, Page No. 5.95"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to copy of entire structure to a function\n",
+ "\n",
+ "class std:\n",
+ " no=0\n",
+ " avg=0.0\n",
+ "\n",
+ "a=std()\n",
+ "\n",
+ "a.no=15\n",
+ "a.avg=90.75\n",
+ "\n",
+ "def func(Struct_p):\n",
+ " print \"Number is.... %d\\n\"%a.no\n",
+ " print \"Average is... %f\"%a.avg\n",
+ " \n",
+ "func(a)\n",
+ "\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Number is.... 15\n",
+ "\n",
+ "Average is... 90.750000\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 7, Page No.:5.97"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "#Programs shows how the structure can be accessed by a pointer variable.\n",
+ "\n",
+ "class student:\n",
+ " roll_no=0\n",
+ " name=''\n",
+ " marks=0.0\n",
+ "stud1=student()\n",
+ "\n",
+ "print \"Enter the student details: \\n\"\n",
+ "stud1.roll_no=input()\n",
+ "stud1.name=raw_input()\n",
+ "stud1.marks=input()\n",
+ "\n",
+ "print \"\\nDisplay of structure using structure variable\\n\"\n",
+ "print \"Roll No\\t Name\\t Marks\"\n",
+ "print \"\\n-------\\t ----- -------\\n\"\n",
+ "print \"%d\\t %s\\t %f\"%(stud1.roll_no,stud1.name,stud1.marks)\n",
+ "\n",
+ "pt=stud1\n",
+ "\n",
+ "print \"\\nDisplay of structure using pointer variable\\n\"\n",
+ "print \"Roll No\\t Name\\t Marks\"\n",
+ "print \"\\n-------\\t ----- -------\\n\"\n",
+ "print \"%d\\t %s\\t %f\"%(pt.roll_no,pt.name,pt.marks)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the student details: \n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "39\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Muni\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "77\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Display of structure using structure variable\n",
+ "\n",
+ "Roll No\t Name\t Marks\n",
+ "\n",
+ "-------\t ----- -------\n",
+ "\n",
+ "39\t Muni\t 77.000000\n",
+ "\n",
+ "Display of structure using pointer variable\n",
+ "\n",
+ "Roll No\t Name\t Marks\n",
+ "\n",
+ "-------\t ----- -------\n",
+ "\n",
+ "39\t Muni\t 77.000000\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 1, Page No.:5.98"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to transfer a structure to a function by passing the structure address to the function\n",
+ "\n",
+ "class struct:\n",
+ " name=''\n",
+ " no=0\n",
+ " age=0\n",
+ "record=struct()\n",
+ "std=record\n",
+ "std.name,std.no,std.age=[\"LAK\",15,25]\n",
+ "print \"%s\\t%d\\t%d\"%(std.name,std.no,std.age)\n",
+ "\n",
+ "def fun(std):\n",
+ " pt.name=\"Muni\"\n",
+ " pt.no=16\n",
+ " pt.age=26\n",
+ " \n",
+ "std.name=pt.name\n",
+ "std.no=pt.no\n",
+ "std.age=pt.age\n",
+ "\n",
+ "print \"%s\\t%d\\t%d\"%(std.name,std.no,std.age)\n",
+ " \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "LAK\t15\t25\n",
+ "Muni\t16\t26\n"
+ ]
+ }
+ ],
+ "prompt_number": 24
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 2, Page No.:5.100"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to pass an array of structure to a function, and return a pointer to a structure.\n",
+ "import sys\n",
+ "N=3\n",
+ "NULL=0\n",
+ "\n",
+ "class struct:\n",
+ " sno=0\n",
+ " name=''\n",
+ " age=0\n",
+ " \n",
+ "record=struct()\n",
+ "std=record\n",
+ "\n",
+ "print \"Student Number Locater\"\n",
+ "print \"To Exit the program enter '0' for student number\"\n",
+ "stdno=input(\"Enter the Student Number: \")\n",
+ "print \"\\n\"\n",
+ "if stdno ==15:\n",
+ "\n",
+ " std.sno,std.name,std.age=[15,\"MUNI\",28]\n",
+ " print \"Number .... %d \\n\"%(std.sno)\n",
+ " print \"Name ...... %s\\n\"%(std.name)\n",
+ " print \"Age ....... %d\\n\"%(std.age)\n",
+ "if stdno == 16:\n",
+ " std.sno,std.name,std.age=[16,\"LAK\",27]\n",
+ " print \"Number .... %d \\n\"%(std.sno)\n",
+ " print \"Name ...... %s\\n\"%(std.name)\n",
+ " print \"Age ....... %d\\n\"%(std.age)\n",
+ " \n",
+ "if stdno == 17:\n",
+ " std.sno,std.name,std.age=[17,\"RAJA\",31]\n",
+ " print \"Number .... %d \\n\"%(std.sno)\n",
+ " print \"Name ...... %s\\n\"%(std.name)\n",
+ " print \"Age ....... %d\\n\"%(std.age)\n",
+ " \n",
+ "if stdno==0:\n",
+ " exit\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Student Number Locater\n",
+ "To Exit the program enter '0' for student number\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student Number: 15\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "\n",
+ "Number .... 15 \n",
+ "\n",
+ "Name ...... MUNI\n",
+ "\n",
+ "Age ....... 28\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 3, Page No.: 5.101"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print student name and mark using structure\n",
+ "\n",
+ "class student:\n",
+ " name=''\n",
+ " marks=0.00\n",
+ " \n",
+ "s1=''\n",
+ "f=0.00\n",
+ "\n",
+ "student1=student()\n",
+ "\n",
+ "student2=student()\n",
+ "\n",
+ "\n",
+ "student1.name=raw_input(\"Enter Name: \")\n",
+ "f=input(\"Enter Mark: \")\n",
+ "\n",
+ "student2.marks=f\n",
+ "\n",
+ "print \"\\nName is %s \\n\"%student1.name\n",
+ "print \"Marks are %f \\n\"%student2.marks\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Name: Venkat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Mark: 89\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Name is Venkat \n",
+ "\n",
+ "Marks are 89.000000 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 4, Page No.: 5.102"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print marks, grade and their address using union\n",
+ "\n",
+ "\n",
+ "\n",
+ "class union_marks:\n",
+ " perc=0.00\n",
+ " grade=''\n",
+ " \n",
+ "student1=union_marks()\n",
+ "\n",
+ "student1.perc=98.5\n",
+ "\n",
+ "print \"Marks are %f \\t address is %8lu\\n\"%(student1.perc, id(student1.perc))\n",
+ "\n",
+ "student1.grade='A'\n",
+ "\n",
+ "print \"Grade is %c \\t address is %8lu\\n\"%(student1.grade,id(student1.grade))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Marks are 98.500000 \t address is 158368916\n",
+ "\n",
+ "Grade is A \t address is 3073485064\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter13.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter13.ipynb
new file mode 100755
index 00000000..b303ee94
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter13.ipynb
@@ -0,0 +1,57 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:bd4e511a3dbdd189491e3271c86cff9ce5fc919ed7457d400a67c288e55ad433"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 13 : Pointers"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page Number: 5.104"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print address and value of variable\n",
+ "#Local definitions\n",
+ "sno = 39\n",
+ "\n",
+ "#Result\n",
+ "print \"Address of sno = %u\" %id(sno)\n",
+ "print \"Value of sno = %d\" %sno"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Address of sno = 20917296\n",
+ "Value of sno = 39\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter14.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter14.ipynb
new file mode 100755
index 00000000..12a1734c
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter14.ipynb
@@ -0,0 +1,234 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:44f5daf77255992c95710d94f062b0f1f1e981b9e6cce07f23ed45a322c4b130"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 14 : Accessing Variable through Pointers"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page Number: 5.107 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to accessing through variable pointer\n",
+ "\n",
+ "from ctypes import c_int\n",
+ "\n",
+ "#Local definition\n",
+ "a = 22\n",
+ "a = c_int(a) # ctype datatype declaration\n",
+ "\n",
+ "b = 2.25\n",
+ "b = c_float(b) # ctype datatype declaration\n",
+ "\n",
+ "#Pointer variables\n",
+ "a_po=pointer(a)\n",
+ "b_po=pointer(b)\n",
+ "\n",
+ "# 'id' is a address of letter and it represents the address of the variable\n",
+ "a = id(a)\n",
+ "b = id(b)\n",
+ "\n",
+ "\n",
+ "#Result\n",
+ "print \"\\nValue of a = %d\" %a_po[0]\n",
+ "print \"\\nValue of b = %.2f\" %b_po[0]\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Value of a = 22\n",
+ "\n",
+ "Value of b = 2.25\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page Number: 5.108"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print address and value of variable\n",
+ "\n",
+ "from ctypes import c_int\n",
+ "\n",
+ "#Local definition\n",
+ "a = 22\n",
+ "a = c_int(a) # ctype datatype declaration\n",
+ "\n",
+ "#Pointer variables\n",
+ "a_po=pointer(a)\n",
+ "\n",
+ "# 'id' is a address of letter and it represents the address of the variable\n",
+ "a = id(a)\n",
+ "\n",
+ "#Result\n",
+ "print \"\\n Value of a = %d\" %a_po[0]\n",
+ "print \"\\n Address of a = %u\" %id(a)\n",
+ "print \"\\n Value at address %u = %d\" %(id(a),a_po[0])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " Value of a = 22\n",
+ "\n",
+ " Address of a = 4344066728\n",
+ "\n",
+ " Value at address 4344066728 = 22\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page Number: 5.108"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "# Program to print value and address of variable\n",
+ "\n",
+ "from ctypes import c_int\n",
+ "\n",
+ "#Local definition\n",
+ "a = 22\n",
+ "b = c_int(a) # ctype datatype declaration\n",
+ "\n",
+ "#Pointer variable\n",
+ "b_po=pointer(b)\n",
+ "\n",
+ "# 'id' is a address of letter and it represents the address of the variable\n",
+ "b = id(a)\n",
+ "\n",
+ "#Result\n",
+ "print \"\\n Value of a = %d\" %a\n",
+ "print \"\\n Value of a = %d\" %(c_int(a).value)\n",
+ "print \"\\n Value of a = %d\" %b_po[0]\n",
+ "print \"\\n Address of a = %u\" %id(a)\n",
+ "print \"\\n Address of a = %u\" %b\n",
+ "print \"\\n Address of a = %u\" %id(b)\n",
+ "print \"\\n Value of b = address of a = %u\" %b"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " Value of a = 22\n",
+ "\n",
+ " Value of a = 22\n",
+ "\n",
+ " Value of a = 22\n",
+ "\n",
+ " Address of a = 4298180848\n",
+ "\n",
+ " Address of a = 4298180848\n",
+ "\n",
+ " Address of a = 4344066728\n",
+ "\n",
+ " Value of b = address of a = 4298180848\n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page Number: 5.109"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to illustrate pointer to pointer\n",
+ "\n",
+ "from ctypes import c_int\n",
+ "\n",
+ "#Local definition\n",
+ "a = 22\n",
+ "b = c_int(a) # ctype datatype declaration\n",
+ "c = c_int(a) # ctype datatype declaration\n",
+ "\n",
+ "#Pointer variable\n",
+ "b_po = pointer(b)\n",
+ "c_po = pointer(b_po) # c_po is a pointer to another pointer\n",
+ "\n",
+ "# 'id' is a address of letter and it represents the address of the variable\n",
+ "b = id(a)\n",
+ "c = id(b)\n",
+ "\n",
+ "#Result\n",
+ "print \"\\n Value of a is %d\" %a\n",
+ "print \"\\n Value of a is %d\" %(c_int(a).value)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ " Value of a is 22\n",
+ "\n",
+ " Value of a is 22\n"
+ ]
+ }
+ ],
+ "prompt_number": 14
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb
new file mode 100755
index 00000000..21b14f41
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter15.ipynb
@@ -0,0 +1,266 @@
+{
+ "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
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb
new file mode 100755
index 00000000..ab91ce85
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter16.ipynb
@@ -0,0 +1,333 @@
+{
+ "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
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter17.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter17.ipynb
new file mode 100755
index 00000000..7967d054
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter17.ipynb
@@ -0,0 +1,310 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:86b94093ee72d30b0a9443a44a1c3905ef6186294337253a1ca56b0318def382"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 17 : Pointers with Multidimensional Array"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.:5.123"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print the values and addres of the array elements.\n",
+ "\n",
+ "arr=([[5,100],[10,200],[15,300],[20,400]])\n",
+ "\n",
+ "for a in range(0,4):\n",
+ " print \"Address of %d array= %u\"%(a,id(arr[a]))\n",
+ " for b in range(0,2):\n",
+ " print \"Value =%d\"%(arr[a][b])\n",
+ "\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Address of 0 array= 4336406328\n",
+ "Value =5\n",
+ "Value =100\n",
+ "Address of 1 array= 4336414944\n",
+ "Value =10\n",
+ "Value =200\n",
+ "Address of 2 array= 4336414800\n",
+ "Value =15\n",
+ "Value =300\n",
+ "Address of 3 array= 4366918504\n",
+ "Value =20\n",
+ "Value =400\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.: 5.125"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print the value and address of the element using array of pointers\n",
+ "\n",
+ "a=[0,1,2]\n",
+ "b=10\n",
+ "c=20\n",
+ "d=30\n",
+ "a[0]=b\n",
+ "a[1]=c\n",
+ "a[2]=d\n",
+ "for i in range(0,3):\n",
+ " print \"Address = %u\"%id(a[i])\n",
+ " print \"Value = %d\" % (a[i])"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Address = 4298181184\n",
+ "Value = 10\n",
+ "Address = 4298180944\n",
+ "Value = 20\n",
+ "Address = 4298180704\n",
+ "Value = 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 8
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No.: 5.126 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to sort a list of strings in alphabetical order using array of pointers.\n",
+ "\n",
+ "a = []\n",
+ "n= input(\"Enter the number of strings: \")\n",
+ "print \"Enter each string on a separate line below.\"\n",
+ "for i in range(0,n):\n",
+ " a.append(0)\n",
+ " \n",
+ "for i in range(0,n):\n",
+ " a[i]=raw_input(\"String %d: \" %(i+1))\n",
+ "for i in range(0,n):\n",
+ " for j in range(i,n):\n",
+ " if a[i]>a[j]:\n",
+ " t = a[i]\n",
+ " a[i] = a[j]\n",
+ " a[j] = t\n",
+ "print \"\\nReordered List of Strings: \"\n",
+ "for i in range(0,n):\n",
+ " print \"String %d: %s\" %(i+1,a[i])\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of strings: 6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter each string on a separate line below.\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String 1: venkat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String 2: ramesh\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String 3: babu\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String 4: muni\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String 5: shankar\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String 6: saravanan\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Reordered List of Strings: \n",
+ "String 1: babu\n",
+ "String 2: muni\n",
+ "String 3: ramesh\n",
+ "String 4: saravanan\n",
+ "String 5: shankar\n",
+ "String 6: venkat\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 4, Page No.: 5.128 "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to count number of words\n",
+ "\n",
+ "str=[]\n",
+ "ps=raw_input(\"Enter a string: \")\n",
+ "print len(ps.split()), \"word(s) in the given string\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter a string: I am a student.\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4 word(s) in the given string\n"
+ ]
+ }
+ ],
+ "prompt_number": 27
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 5, Page No.: 5.129"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate on strings and pointers\n",
+ "\n",
+ "s1=\"abcd\"\n",
+ "s2='efgh'\n",
+ "\n",
+ "print \"%s %16lu \\n\" % (s1,id(s1))\n",
+ "print \"%s %16lu \\n\" % (s2,id(s2)) \n",
+ "\n",
+ "s1=s2\n",
+ "print \"%s %16lu \\n\" % (s1,id(s1))\n",
+ "print \"%s %16lu \\n\" % (s2,id(s2))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "abcd 4363408224 \n",
+ "\n",
+ "efgh 4363332704 \n",
+ "\n",
+ "efgh 4363332704 \n",
+ "\n",
+ "efgh 4363332704 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter18.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter18.ipynb
new file mode 100755
index 00000000..c422da50
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter18.ipynb
@@ -0,0 +1,490 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:0724a7e756186f06943f5403b91daf5f178ee495f014e11c1fad0330aa0d254c"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 18 : Pointers and Structures"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.: 5.130"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print details of person using structure and pointer\n",
+ "\n",
+ "class account:\n",
+ " name=\"\"\n",
+ " place=\"\"\n",
+ " acctno=0\n",
+ " \n",
+ "m4=account()\n",
+ "m4.name=\"Venkat\"\n",
+ "m4.place=\"Arcot\"\n",
+ "m4.acctno=24201\n",
+ "\n",
+ "print \"%s\\t%s\\t%d\\n\"%(m4.name,m4.place,m4.acctno)\n",
+ "\n",
+ "contents=m4\n",
+ "\n",
+ "print \"%s\\t%s\\t%d\\n\"%(contents.name,contents.place,contents.acctno)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Venkat\tArcot\t24201\n",
+ "\n",
+ "Venkat\tArcot\t24201\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 2
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No.: 5.131"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to print name, place, and account number using structure and pointer\n",
+ "\n",
+ "class account:\n",
+ " name=\"\"\n",
+ " place=\"\"\n",
+ " acctno=0\n",
+ " \n",
+ "m4=account()\n",
+ "m4.name=\"Madhavan\"\n",
+ "m4.place=\"Chennai\"\n",
+ "m4.acctno=241\n",
+ "a=m4\n",
+ "\n",
+ "print \"%s\\n%s\\n%d\\n\"%(a.name,a.place,a.acctno)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Madhavan\n",
+ "Chennai\n",
+ "241\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 7
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No.: 5.132"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to show how the int_pointers structure can be handled.\n",
+ "\n",
+ "\n",
+ "class int_pointers:\n",
+ " p1=0\n",
+ " p2=0\n",
+ " \n",
+ "pointers=int_pointers()\n",
+ "m1= 80\n",
+ "pointers.p1=m1\n",
+ "pointers.p2=-40\n",
+ "m2=pointers.p2\n",
+ "print \"m1= %i, *pointers.p1 = %i\\n\"% (m1,pointers.p1)\n",
+ "print \"m2= %i, *pointers.p2 = %i\\n\"% (m2,pointers.p2)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "m1= 80, *pointers.p1 = 80\n",
+ "\n",
+ "m2= -40, *pointers.p2 = -40\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 15
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 1: Page No.5.133"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to interchange the values stored in two variables using function with pointers. \n",
+ "\n",
+ "def interchange(a,b):\n",
+ " t=a\n",
+ " a=b\n",
+ " b=t\n",
+ " return b,a\n",
+ " \n",
+ "a=39\n",
+ "b=77\n",
+ "\n",
+ "print \"Before Interchange: a=%d, b=%d\"%(a,b)\n",
+ "\n",
+ "\n",
+ "print \"After Interchange : a=%d, b=%d\"%(interchange(b,a))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Before Interchange: a=39, b=77\n",
+ "After Interchange : a=77, b=39\n"
+ ]
+ }
+ ],
+ "prompt_number": 16
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study: 2, Page No.:5.134"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate the use of structure pointers\n",
+ "\n",
+ "class book:\n",
+ " bno=0\n",
+ " bname=''\n",
+ " cost=0.0\n",
+ "\n",
+ "p=[book()for i in range(0,3)]\n",
+ "print \"Enter the Book details... \"\n",
+ "print \"Enter Book number, Book Name, Book Costs... \"\n",
+ "for i in range(0,3):\n",
+ " p[i].bno=input()\n",
+ " p[i].bname=raw_input()\n",
+ " p[i].cost=input()\n",
+ " \n",
+ "for i in range(0,3):\n",
+ " \n",
+ " print \"\\n%d\\t%s\\t\\t%d\"%(p[i].bno,p[i].bname,p[i].cost)\n",
+ " \n",
+ "print \"\\nStructure Output\\n\"\n",
+ "ptr=p\n",
+ "\n",
+ "for i in range(0,3):\n",
+ " print \"%d\\t%s\\t\\t%d\"%(ptr[i].bno,ptr[i].bname,ptr[i].cost)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Book details... \n",
+ "Enter Book number, Book Name, Book Costs... \n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "101\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Computer Practice_1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "240\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "201\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Computer Practice_2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "250\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "202\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "C++ and JAVA\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "280\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "101\tComputer Practice_1\t240\n",
+ "\n",
+ "201\tComputer Practice_2\t250\n",
+ "\n",
+ "202\tC++ and JAVA\t280\n",
+ "\n",
+ "Structure Output\n",
+ "\n",
+ "101\tComputer Practice_1\t240\n",
+ "201\tComputer Practice_2\t250\n",
+ "202\tC++ and JAVA\t280\n"
+ ]
+ }
+ ],
+ "prompt_number": 46
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 3: Page No: 5.136"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to count number of vowels,consonants, digits,spaces and other characters in a line of text.\n",
+ "\n",
+ "vowels='aeiou'\n",
+ "consonants='bcdfghjklmnpqrstvwxyz'\n",
+ "spaces =' '\n",
+ "digits='1234567890'\n",
+ "special_characters='!@#$%^&*()_'\n",
+ "\n",
+ "text=raw_input(\"Enter the text in lower case: \")\n",
+ "\n",
+ "print \"\\nNumber of vowels: \",dict((v, text.count(v)) for v in text if v in vowels)\n",
+ "print \"Number of consonants: \",dict((c, text.count(c)) for c in text if c in consonants)\n",
+ "print \"Number of Spaces: \",dict((s, text.count(s)) for s in text if s in spaces)\n",
+ "print \"Number of digits: \",dict((d, text.count(d)) for d in text if d in digits)\n",
+ "print \"Number of special_characters: \",dict((sc, text.count(sc)) for sc in text if sc in special_characters)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the text in lower case: 123 vrb publishers @#$%^&*()\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Number of vowels: {'i': 1, 'e': 1, 'u': 1}\n",
+ "Number of consonants: {'b': 2, 'h': 1, 'l': 1, 'p': 1, 's': 2, 'r': 2, 'v': 1}\n",
+ "Number of Spaces: {' ': 3}\n",
+ "Number of digits: {'1': 1, '3': 1, '2': 1}\n",
+ "Number of special_characters: {'@': 1, '#': 1, '%': 1, '$': 1, '&': 1, ')': 1, '(': 1, '*': 1, '^': 1}\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 4: Page No.: 5.136"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate malloc() function\n",
+ "\n",
+ "NULL=0\n",
+ "string = ''\n",
+ "if string==NULL:\n",
+ " print \"Not Enough memory to allocate buffer\\n\"\n",
+ "else:\n",
+ " \n",
+ " def strcpy(cstring1):\n",
+ " import copy\n",
+ " cstring2=copy.copy(cstring1)\n",
+ " return cstring2 \n",
+ "string=\"Hello\"\n",
+ "print \"String is %s\" %string"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String is Hello\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 5: Page No.: 5.137"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate calloc() function\n",
+ "\n",
+ "string=''\n",
+ "\n",
+ "def strcpy(cstring1):\n",
+ " import copy\n",
+ " cstring2=copy.copy(cstring1)\n",
+ " return cstring2 \n",
+ "stri=\"BHAVANA\"\n",
+ "string=strcpy(stri)\n",
+ "print \"String is %s\" %string"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "String is BHAVANA\n"
+ ]
+ }
+ ],
+ "prompt_number": 20
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Case Study 6: Page No.:5.138"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to demonstrate realloc() function\n",
+ "#Cannot do in python"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [],
+ "prompt_number": 29
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter19.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter19.ipynb
new file mode 100755
index 00000000..bbaf1a5b
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter19.ipynb
@@ -0,0 +1,126 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:069422c07d34cc73268583e26cec775bbe1b3930cb154b474b2ff1e109dbe593"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 19 : Command Line Arguments"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No.:5.139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "\n",
+ "import sys\n",
+ "argc=0\n",
+ "if argc!=2:\n",
+ " print \"Hellow %s\"%(sys.argv)\n",
+ "else:\n",
+ " print \"Forgotted to type name\"\n",
+ " exit(0)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Hellow ['-c', '-f', '/home/gayathri/.config/ipython/profile_default/security/kernel-f732916e-2a20-4211-8210-1c4fa7115bd5.json', \"--IPKernelApp.parent_appname='ipython-notebook'\", '--profile-dir', '/home/gayathri/.config/ipython/profile_default', '--parent=1']\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 2, Page No. 5.139"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import sys\n",
+ "\n",
+ "argc='0'\n",
+ "if argc==2:\n",
+ " print \"Argument supplied is %s\"%(sys.argv)\n",
+ "elif argc>2:\n",
+ " print \"Too many arguments supplied \\n\",(sys.argv)\n",
+ "else:\n",
+ " print \"One Argument expected\",(sys.argv)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Too many arguments supplied \n",
+ "['-c', '-f', '/home/gayathri/.config/ipython/profile_default/security/kernel-f732916e-2a20-4211-8210-1c4fa7115bd5.json', \"--IPKernelApp.parent_appname='ipython-notebook'\", '--profile-dir', '/home/gayathri/.config/ipython/profile_default', '--parent=1']\n"
+ ]
+ }
+ ],
+ "prompt_number": 6
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 3, Page No. :5.140"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "import sys\n",
+ "\n",
+ "\n",
+ "print \"The Arguments to the program are: \"\n",
+ "print str(sys.argv)\n",
+ " \n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Arguments to the program are: \n",
+ "['-c', '-f', '/home/gayathri/.config/ipython/profile_default/security/kernel-f732916e-2a20-4211-8210-1c4fa7115bd5.json', \"--IPKernelApp.parent_appname='ipython-notebook'\", '--profile-dir', '/home/gayathri/.config/ipython/profile_default', '--parent=1']\n"
+ ]
+ }
+ ],
+ "prompt_number": 30
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter20.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter20.ipynb
new file mode 100755
index 00000000..adaadc6f
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter20.ipynb
@@ -0,0 +1,61 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:7f2d14f2c2ae43d8abc01634eb7d39800f8596aa61628d10404d3502e1e30c64"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 20 : Dynamic Memory Allocation"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Example: 1, Page No. 5.146"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Reallocation of memory\n",
+ "\n",
+ "p= \"MADRAS\"\n",
+ "\n",
+ "print \"Memory contains: %s\\n\"%(p) #There is no reallocation memory in python\n",
+ "\n",
+ "p=\"CHENNAI\"\n",
+ "\n",
+ "print \"Memory now contains: %s\\n\"%(p)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Memory contains: MADRAS\n",
+ "\n",
+ "Memory now contains: CHENNAI\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb
new file mode 100755
index 00000000..2b76d2a2
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb
@@ -0,0 +1,174 @@
+{
+ "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": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/Chapter22.ipynb b/Fundamental_of_Computing_and_Programming_in_C/Chapter22.ipynb
new file mode 100755
index 00000000..53a104bf
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/Chapter22.ipynb
@@ -0,0 +1,2300 @@
+{
+ "metadata": {
+ "name": "",
+ "signature": "sha256:dd103cfe67b47eb61e56816517923337936d461ec4fd4b8f9f87e6c544fd31e3"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+ {
+ "cells": [
+ {
+ "cell_type": "heading",
+ "level": 1,
+ "metadata": {},
+ "source": [
+ "Chapter 22 : Sample C Programs(Lab Exercise)"
+ ]
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 1: Page no.:L.4"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Area of Triangle\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "#User Inputs\n",
+ "a,b,c=input(\"Enter three sides: \")\n",
+ "\n",
+ "#calculation of semi perimeter\n",
+ "s=(a+b+c)/2\n",
+ "\n",
+ "#Calculation of Area of Triangle\n",
+ "d=(s*(s-a)*(s-b)*(s-c))\n",
+ "\n",
+ "area=math.sqrt(d)\n",
+ "\n",
+ "#Result\n",
+ "print \"Area of triangle = %f sq units \\n\"%area"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter three sides: 5,6,7\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Area of triangle = 14.696938 sq units \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 5
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 2: Page No. L.5"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Square root for the given value.\n",
+ "\n",
+ "import math\n",
+ "\n",
+ "#User Input\n",
+ "x=input(\"Enter the Value: \")\n",
+ "\n",
+ "#Result\n",
+ "print \"Square root of %.2f is: \"%(x)\n",
+ "\n",
+ "print math.sqrt(x)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Value: 81\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Square root of 81.00 is: \n",
+ "9.0\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 3: Page.No.L.6"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Sum of the series 0+1+(1+2)+...+n\n",
+ "\n",
+ "#User Input\n",
+ "n=input(\"Enter the Value of n : \")\n",
+ "\n",
+ "#Variable Declaration\n",
+ "s=term=0\n",
+ "i=j=0\n",
+ "\n",
+ "#Computing Values in loop\n",
+ "for i in range(n):\n",
+ " for j in range(n):\n",
+ " if j<=i:\n",
+ " term=term+j\n",
+ " j=j+1 \n",
+ "s=s+term\n",
+ "if i<=n:\n",
+ " i=i+1\n",
+ " \n",
+ "#Result\n",
+ "print \"Sum of the series S= %d\"%(s)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Value of n :5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Sum of the series S= 20\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 4: Page No.:L.9"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Decimal into binary number.\n",
+ "\n",
+ "n=input(\"Enter the decimal number: \")\n",
+ "s=n\n",
+ "k=[]\n",
+ "\n",
+ "#Calculation\n",
+ "while (s>0):\n",
+ " a=int(float(s%2))\n",
+ " k.append(a)\n",
+ " s=(s-a)/2\n",
+ "k.append(0)\n",
+ "bi=\"\"\n",
+ "\n",
+ "for j in k[::1]:\n",
+ " bi=bi+str(j)\n",
+ "\n",
+ "#Result\n",
+ "print('The binary value of %d is %s'%(n, bi))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the decimal number: 14\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The binary value of 14 is 01110\n"
+ ]
+ }
+ ],
+ "prompt_number": 1
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 5: Page No. L.10"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#The given number is armstrong or not.\n",
+ "\n",
+ "#Variable declaration\n",
+ "a=b=c=d=e=0\n",
+ "\n",
+ "#User Input\n",
+ "a=input(\"Enter the Number: \")\n",
+ "\n",
+ "#Assigning variable 'a' value to variable 'e'\n",
+ "e=a\n",
+ "\n",
+ "#Calculation for finding Armstrong or not\n",
+ "while a>0:\n",
+ " b=a%10\n",
+ " c=b*b*b\n",
+ " a=a/10\n",
+ " d=c+d\n",
+ " \n",
+ "#Result\n",
+ "if e==d:\n",
+ " print \"%d is an armstrong number. \"%e\n",
+ " \n",
+ "else:\n",
+ " print \"%d is not an armstrong number. \"%e"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Number: 153\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "153 is an armstrong number. \n"
+ ]
+ }
+ ],
+ "prompt_number": 10
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 6: Page No.L.12"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Centigrade and Farenheit Values.\n",
+ "\n",
+ "\n",
+ "#Variable Declaration\n",
+ "c=f=cn=fn=0.0\n",
+ "\n",
+ "#User Input1 for calculating farenheit\n",
+ "c=input(\"Enter temperature in centigrade : \")\n",
+ "\n",
+ "#Farenheit Calculation\n",
+ "f=1.8*c+32\n",
+ "\n",
+ "#Result1\n",
+ "print \"Farenheit Equivalent is: %.1f\\n\" %(f)\n",
+ "\n",
+ "#User input2 for calculating centigrade\n",
+ "fn=input(\"Enter temperature in farenheit : \")\n",
+ "\n",
+ "#Centigrade Calculation\n",
+ "cn=(fn-32)/1.8\n",
+ "\n",
+ "#Result2\n",
+ "print \"Centigrade Equivalent is : %.1f\\n\"%(cn)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter temperature in centigrade : 20\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Farenheit Equivalent is: 68.0\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter temperature in farenheit : 68\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Centigrade Equivalent is : 20.0\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 11
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 7: Page .no.L.13"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Converting Decimal value to binary number\n",
+ "\n",
+ "\n",
+ "#Variable declaration\n",
+ "bnum=digit=decimal=bina=base=0\n",
+ "\n",
+ "#User input\n",
+ "bnum=input(\"Enter the binary number: \")\n",
+ "\n",
+ "bina=bnum\n",
+ "\n",
+ "while(bnum!=0):\n",
+ " digit=bnum%10\n",
+ " decimal=decimal+(digit<<base)\n",
+ " base=base+1\n",
+ " bnum=bnum/10\n",
+ " \n",
+ "print \"The binary equivalent of %d in decimal = %d\"%(bina,decimal)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the binary number: 1111\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The binary equivalent of 1111 in decimal = 15\n"
+ ]
+ }
+ ],
+ "prompt_number": 12
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 8: Page no.L.15"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Reverse number of the given number.\n",
+ "\n",
+ "#Function Definition.\n",
+ "def rev(n):\n",
+ " digit=rev_of=0\n",
+ " while n!=0:\n",
+ " digit=n%10\n",
+ " rev_of=rev_of*10+digit\n",
+ " n=n/10\n",
+ " return rev_of\n",
+ "\n",
+ "#Variable Declaration\n",
+ "\n",
+ "\n",
+ "#User input\n",
+ "p=input(\"Enter the number: \")\n",
+ "\n",
+ "q=rev(p)\n",
+ "\n",
+ "print \"Reverse of %d is %d.\\n\"%(p,q)\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number: 1234\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Reverse of 1234 is 4321.\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 22
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 9: Page no.L.17"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Square of given value\n",
+ "\n",
+ "#Function definition\n",
+ "def square(y):\n",
+ " return y*y\n",
+ "\n",
+ "#User input\n",
+ "n=input(\"Enter the nth element : \")\n",
+ "\n",
+ "#Calculation\n",
+ "for x in range(1,n+1):\n",
+ " print \"%d \" %(square(x))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the nth element : 8\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1 \n",
+ "4 \n",
+ "9 \n",
+ "16 \n",
+ "25 \n",
+ "36 \n",
+ "49 \n",
+ "64 \n"
+ ]
+ }
+ ],
+ "prompt_number": 29
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 10: Page no.:L.18"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Maximum value of given numbers\n",
+ "\n",
+ "#Function definition\n",
+ "def maximum(x,y,z):\n",
+ " \n",
+ " maxi=x\n",
+ " if y>maxi:\n",
+ " maxi=y\n",
+ " if z>maxi:\n",
+ " maxi=z\n",
+ " return maxi\n",
+ " \n",
+ " \n",
+ "#User input\n",
+ "a,b,c=input(\"Enter three integers : \")\n",
+ "\n",
+ "#Result\n",
+ "print \"Maximum is : %d\\n\"%(maximum(a,b,c))\n",
+ "\n",
+ "\n",
+ " \n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter three integers : 2,6,9\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Maximum is : 9\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 34
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 11: Page no.L.19"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Factorial of the given number using recursion.\n",
+ "\n",
+ "#funtion declaration\n",
+ "def fact(n):\n",
+ " if n==0:\n",
+ " return 1\n",
+ " else:\n",
+ " return(n*fact(n-1))\n",
+ " \n",
+ "#USer Input\n",
+ "\n",
+ "n=input(\"Enter the number whose factorial is to be found: \")\n",
+ "\n",
+ "#Result\n",
+ "print \"The Factorial of %d is : %d \\n\"%(n,fact(n))"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number whose factorial is to be found: 6\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The Factorial of 6 is : 720 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 36
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 12: Page no.L.20"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Palindrome or not.\n",
+ "\n",
+ "print \"Enter the String to check palindrome or not \\n\"\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "string = raw_input(\"Enter the String: \")\n",
+ "\n",
+ "#reverse the string \n",
+ "\n",
+ "rev_string = reversed(string)\n",
+ "\n",
+ "#Check if the string is palindrome or not\n",
+ "\n",
+ "if list(rev_string) == list(string) :\n",
+ " print \"\\nThe given string %s is a palindrome\"%(string)\n",
+ " \n",
+ "else:\n",
+ " print \"\\nThe given string %s is not a palindrome\"%(string)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the String to check palindrome or not \n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the String: madam\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "The given string madam is a palindrome\n"
+ ]
+ }
+ ],
+ "prompt_number": 9
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 13: Page No. L.24"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Largest and smallest number in array\n",
+ "\n",
+ "#User input\n",
+ "n= input(\"Enter the nth term of an array: \")\n",
+ "\n",
+ "for i in range(0,n):\n",
+ " a[i]=eval(raw_input())\n",
+ "\n",
+ "#check if the given array is large or small. \n",
+ " for i in range(1,n):\n",
+ " if a[i]>large:\n",
+ " large=a[i]\n",
+ " \n",
+ " else:\n",
+ " if a[i]<small:\n",
+ " small=a[i]\n",
+ " \n",
+ " \n",
+ "print \"Largest element in an array is: %.2f\"%large\n",
+ "print \"Smallest element in an array is: %.2f\"%small\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the nth term of an array: 4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "12\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "79\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "50\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-21\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Largest element in an array is: 79.00\n",
+ "Smallest element in an array is:-21.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 40
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 14: Page no. L.26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Given array in ascending order\n",
+ "\n",
+ "#User Input\n",
+ "n=input(\"Enter the last term of the array: \")\n",
+ "\n",
+ "for i in range(0,n):\n",
+ " a[i]=eval(raw_input())\n",
+ "for i in range(0,n-1):\n",
+ "\n",
+ " for j in range(i+1,n):\n",
+ " if a[i]>a[j]:\n",
+ " temp=a[i]\n",
+ " a[i]=a[j]\n",
+ " a[j]=temp\n",
+ " \n",
+ "print \"\\nThe Elements in ascending order\\n\"\n",
+ "\n",
+ "for i in range(0,n):\n",
+ " print \"%.2f\"%a[i]"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the last term of the array: 6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "23\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "14\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-90\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "-67\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "48\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "01\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "The Elements in ascending order\n",
+ "\n",
+ "-90.00\n",
+ "-67.00\n",
+ "1.00\n",
+ "14.00\n",
+ "23.00\n",
+ "48.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 47
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 15: Page No. L.27"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Insert element in specified position in an array\n",
+ "\n",
+ "import array\n",
+ "\n",
+ "#User input\n",
+ "n=input(\"Enter the last value: \")\n",
+ "a=[0 for i in range(0,n) ]\n",
+ "print \"Enter the elements of array: \"\n",
+ "for i in range(0,n):\n",
+ " a[i]=eval(raw_input())\n",
+ " \n",
+ "#Getting inserting element and position from users\n",
+ "item=input(\"Enter the element to be inserted: \")\n",
+ "pos=input(\"Enter the position of insertion: \")\n",
+ "a.insert(pos,item)\n",
+ "#Result\n",
+ "print \"\\nElements after insertion is : \"\n",
+ "for i in range(0,n+1):\n",
+ " print \"%.2f\"%a[i]\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the last value: 5\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements of array: \n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "12\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "34\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "56\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "90\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "32\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the element to be inserted: 36\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the position of insertion: 4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Elements after insertion is : \n",
+ "12.00\n",
+ "34.00\n",
+ "56.00\n",
+ "90.00\n",
+ "36.00\n",
+ "32.00\n"
+ ]
+ }
+ ],
+ "prompt_number": 3
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 16: Page.no.L.29"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Transpose of the matrix\n",
+ "\n",
+ "#User Input\n",
+ "\n",
+ "a=[]\n",
+ "\n",
+ "n,m=input(\"Enter the Row and Columns: \")\n",
+ "print \"Enter the elements of matrix:\"\n",
+ "for i in range(n):\n",
+ " a.append([])\n",
+ " \n",
+ " for j in range(m):\n",
+ " element=input()\n",
+ " a[i].append(element)\n",
+ "\n",
+ "#print matrix\n",
+ "print \"\\nElements in matrix: \"\n",
+ "for i in range(n):\n",
+ " for j in range(m):\n",
+ " print a[i][j],\n",
+ " print '\\n'\n",
+ "\n",
+ "\n",
+ "#generate transpose\n",
+ "transpose=[]\n",
+ "for j in range(m):\n",
+ " transpose.append([])\n",
+ " for i in range (n):\n",
+ " b=a[i][j]\n",
+ " transpose[j].append(b)\n",
+ "\n",
+ "#print transpose\n",
+ "print \"Transpose of the matrix is: \"\n",
+ "for i in range (m):\n",
+ " for j in range (n):\n",
+ " print transpose[i][j],\n",
+ " print '\\n'\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns: 3,3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements of matrix:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "9\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Elements in matrix: \n",
+ "1 2 3 \n",
+ "\n",
+ "4 5 6 \n",
+ "\n",
+ "7 8 9 \n",
+ "\n",
+ "Transpose of the matrix is: \n",
+ "1 4 7 \n",
+ "\n",
+ "2 5 8 \n",
+ "\n",
+ "3 6 9 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 52
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 17: Page no. L.32"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to find sum of an array matrix\n",
+ "#Array Declaration\n",
+ "\n",
+ "a=[]\n",
+ "b=[]\n",
+ "c=[[0 for i in xrange(0,5)] for i in xrange(0,5)]\n",
+ "#User Input1\n",
+ "n,m=input(\"Enter the Row and Columns of A Matrix: \")\n",
+ "print \"Enter the elements of A matrix:\"\n",
+ "for i in range(n):\n",
+ " a.append([])\n",
+ " \n",
+ " for j in range(m):\n",
+ " element=input()\n",
+ " a[i].append(element)\n",
+ "\n",
+ "#print matrix1\n",
+ "print \"\\nElements in A matrix: \"\n",
+ "for i in range(n):\n",
+ " for j in range(m):\n",
+ " print a[i][j],\n",
+ " print '\\n'\n",
+ "\n",
+ " \n",
+ "#User Input 2\n",
+ "p,q=input(\"Enter the Row and Columns of B Matrix: \")\n",
+ "print \"Enter the elements of B matrix:\"\n",
+ "for i in range(p):\n",
+ " b.append([])\n",
+ " \n",
+ " for j in range(q):\n",
+ " element=input()\n",
+ " b[i].append(element)\n",
+ "\n",
+ "#print matrix 2\n",
+ "print \"\\nElements in B matrix: \"\n",
+ "for i in range(p):\n",
+ " for j in range(q):\n",
+ " print b[i][j],\n",
+ " print '\\n'\n",
+ "\n",
+ "#Addition of array in matrix \n",
+ "for i in range(n):\n",
+ " for j in range(m):\n",
+ " c[i][j] += a[i][j] + b[i][j]\n",
+ "\n",
+ "#Result\n",
+ "print \"\\nThe Sum of A and B matrix: \"\n",
+ "for i in range(n):\n",
+ " for j in range(m):\n",
+ " print \"%5d\"%c[i][j],\n",
+ " print '\\n'"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns of A Matrix: 3,3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements of A matrix:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "9\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Elements in A matrix: \n",
+ "1 2 3 \n",
+ "\n",
+ "4 5 6 \n",
+ "\n",
+ "7 8 9 \n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns of B Matrix: 3,3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements of B matrix:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Elements in B matrix: \n",
+ "1 2 3 \n",
+ "\n",
+ "4 5 6 \n",
+ "\n",
+ "6 7 4 \n",
+ "\n",
+ "\n",
+ "The Sum of A and B matrix: \n",
+ " 2 4 6 \n",
+ "\n",
+ " 8 10 12 \n",
+ "\n",
+ " 13 15 13 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 80
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 18: Page No. :L.35"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to find Matrix Multiplication \n",
+ "#Array Declaration\n",
+ "\n",
+ "a=[]\n",
+ "b=[]\n",
+ "c=[[0 for i in xrange(0,5)] for i in xrange(0,5)]\n",
+ "\n",
+ "while True:\n",
+ "#User Input1\n",
+ " n,m=input(\"Enter the Row and Columns of A Matrix: \")\n",
+ " p,q=input(\"Enter the Row and Columns of B Matrix: \")\n",
+ " if (n==m&p==q):\n",
+ " print \"Enter the elements of A matrix:\" \n",
+ " for i in range(n):\n",
+ " a.append([]) \n",
+ " for j in range(m):\n",
+ " element=input()\n",
+ " a[i].append(element)\n",
+ "#print matrix1\n",
+ " print \"\\nElements in A matrix: \"\n",
+ " for i in range(n):\n",
+ " for j in range(m):\n",
+ " print a[i][j],\n",
+ " print '\\n'\n",
+ " \n",
+ "#User Input 2 \n",
+ " print \"Enter the elements of B matrix:\"\n",
+ " for i in range(p):\n",
+ " b.append([])\n",
+ " for j in range(q):\n",
+ " element=input()\n",
+ " b[i].append(element)\n",
+ "\n",
+ "#print matrix 2\n",
+ " print \"\\nElements in B matrix: \"\n",
+ " for i in range(p):\n",
+ " for j in range(q):\n",
+ " print b[i][j],\n",
+ " print '\\n'\n",
+ "\n",
+ "#Multiplication of array in matrix \n",
+ " for i in range(0,m):\n",
+ " for j in range(0,n):\n",
+ " c[i][j] = 0\n",
+ " for k in range(0,n):\n",
+ " c[i][j] += a[i][k] * b[k][j]\n",
+ " \n",
+ "#Result\n",
+ " print \"\\nThe Multiplication of A and B matrix: \"\n",
+ " for i in range(n):\n",
+ " for j in range(m):\n",
+ " print \"%5d\"%c[i][j],\n",
+ " print '\\n'\n",
+ " break\n",
+ " else:\n",
+ " print \"The No. of rows and columns are not equal.\\n\""
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns of A Matrix: 3,3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns of B Matrix: 2,2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "The No. of rows and columns are not equal.\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns of A Matrix: 3,3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Row and Columns of B Matrix: 3,3\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the elements of A matrix:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "8\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "9\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Elements in A matrix: \n",
+ "1 2 3 \n",
+ "\n",
+ "4 5 6 \n",
+ "\n",
+ "7 8 9 \n",
+ "\n",
+ "Enter the elements of B matrix:\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "2\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "4\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "1\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "6\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": [
+ "3\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "5\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "7\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Elements in B matrix: \n",
+ "2 4 1 \n",
+ "\n",
+ "6 7 4 \n",
+ "\n",
+ "3 5 7 \n",
+ "\n",
+ "\n",
+ "The Multiplication of A and B matrix: \n",
+ " 23 33 30 \n",
+ "\n",
+ " 56 81 66 \n",
+ "\n",
+ " 89 129 102 \n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 93
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 19: Page No. L.38"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Student grade using structure\n",
+ "\n",
+ "#User Input\n",
+ "n=input(\"Enter the number of students: \")\n",
+ "\n",
+ "#Defining Structure\n",
+ "class std:\n",
+ " no=0\n",
+ " name = ''\n",
+ " m1 = m2 = m3 =0\n",
+ " total=avg=0.0\n",
+ " grade= ''\n",
+ " \n",
+ "s=[std() for i in range(0,n)]\n",
+ "\n",
+ "#User Input\n",
+ "for i in range(0,n):\n",
+ " print \"\\nEnter the student %d details\"%(i+1)\n",
+ " print \"\\n\"\n",
+ " s[i].no=int(input(\"Give Student Number: \"))\n",
+ " s[i].name=raw_input(\"Enter the Student Name: \")\n",
+ " s[i].m1=int(input(\"Enter Student Mark1: \"))\n",
+ " s[i].m2=int(input(\"Enter Student Mark2: \"))\n",
+ " s[i].m3=int(input(\"Enter Student Mark3: \"))\n",
+ "\n",
+ "\n",
+ "#Calculation \n",
+ " s[i].total = (s[i].m1 + s[i].m2 + s[i].m3)\n",
+ " s[i].avg=(s[i].total / 3)\n",
+ " if s[i].avg<=40:\n",
+ " s[i].grade='D'\n",
+ " elif s[i].avg<60:\n",
+ " s[i].grade='C'\n",
+ " elif s[i].avg<80:\n",
+ " s[i].grade='B'\n",
+ " else:\n",
+ " s[i].grade='A'\n",
+ " \n",
+ "#Result\n",
+ "print \"\\tStudent mark details.... \\n\"\n",
+ "print \"Roll No\\t Name \\t\\tMark1 \\tMark2 \\tMark3 \\tTotal \\tAverage \\tGrade\"\n",
+ "for i in range(0,n):\n",
+ " print \"%d\\t\"%(s[i].no),\"%s\\t\\t\"%(s[i].name), \"%d\\t\"%(s[i].m1),\"%d\\t\"%(s[i].m2),\"%d\\t\"%(s[i].m3), \"%.2f\\t\"%(s[i].total), \"%.2f\\t\\t\"%(s[i].avg), \"%s\\t\"%(s[i].grade)\n",
+ " "
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the number of students: 2\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Enter the student 1 details\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give Student Number: 100\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student Name: Venkat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark1: 89\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark2: 87\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark3: 76\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "Enter the student 2 details\n",
+ "\n",
+ "\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Give Student Number: 101\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Student Name: Shankar\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark1: 87\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark2: 90\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter Student Mark3: 67\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\tStudent mark details.... \n",
+ "\n",
+ "Roll No\t Name \t\tMark1 \tMark2 \tMark3 \tTotal \tAverage \tGrade\n",
+ "100\tVenkat\t\t89\t87\t76\t252.00\t84.00\t\tA\t\n",
+ "101\tShankar\t\t87\t90\t67\t244.00\t81.00\t\tA\t\n"
+ ]
+ }
+ ],
+ "prompt_number": 43
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 20: Page No. L.40"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Employee details using Union\n",
+ "\n",
+ "#Defining Union\n",
+ "\n",
+ "class union:\n",
+ " name=\"\"\n",
+ " idno=0\n",
+ " salary=0.0\n",
+ " \n",
+ "desc=union()\n",
+ "\n",
+ "desc.name=\"vinod\"\n",
+ "\n",
+ "print \"Employee details:\"\n",
+ "\n",
+ "print \"The name is %s\\n\"%(desc.name)\n",
+ "print \"The idno is %d\\n\"%(desc.idno)\n",
+ "print \"The salary is %6.2f\\n\"%(desc.salary)\n",
+ "\n",
+ "desc.idno=10\n",
+ "\n",
+ "print \"Employe details:\"\n",
+ "\n",
+ "print \"The name is %s\\n\"%(desc.name)\n",
+ "print \"The idno is %d\\n\"%(desc.idno)\n",
+ "print \"The salary is %6.2f\\n\"%(desc.salary)\n",
+ "\n",
+ "desc.salary=6500.00\n",
+ "\n",
+ "print \"Employee details:\"\n",
+ "\n",
+ "print \"The name is %s\\n\"%(desc.name)\n",
+ "print \"The idno is %d\\n\"%(desc.idno)\n",
+ "print \"The salary is %6.2f\\n\"%(desc.salary)"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Employee details:\n",
+ "The name is vinod\n",
+ "\n",
+ "The idno is 0\n",
+ "\n",
+ "The salary is 0.00\n",
+ "\n",
+ "Employe details:\n",
+ "The name is vinod\n",
+ "\n",
+ "The idno is 10\n",
+ "\n",
+ "The salary is 0.00\n",
+ "\n",
+ "Employee details:\n",
+ "The name is vinod\n",
+ "\n",
+ "The idno is 10\n",
+ "\n",
+ "The salary is 6500.00\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 58
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 21: Page No. L.41"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Swap the contents of two variable using pointer.\n",
+ "\n",
+ "#swapping function.\n",
+ "\n",
+ "def interchange(x,y):\n",
+ " temp=x\n",
+ " x=y\n",
+ " y=temp\n",
+ " return x,y\n",
+ "\n",
+ "#User Input\n",
+ "a,b = input(\"Enter the values of A and B: \")\n",
+ "#Result before interchanging\n",
+ "print \"a=%d b=%d\\n\"%(a,b)\n",
+ "\n",
+ "\n",
+ "#Result after interchanging\n",
+ "print \"After interchanging: \\n\"\n",
+ "\n",
+ "print \"a=%d b=%d\\n\"%(interchange(a,b))\n"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the values of A and B: 23,56\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "a=23 b=56\n",
+ "\n",
+ "After interchanging: \n",
+ "\n",
+ "a=56 b=23\n",
+ "\n"
+ ]
+ }
+ ],
+ "prompt_number": 66
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 22: Page No.: L.43"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Concatenate two strings using Dynamic Memory Allocation \n",
+ "\n",
+ "s1= raw_input(\"Enter String One: \")\n",
+ "s2=raw_input(\"Enter String two: \")\n",
+ "\n",
+ "s3=''\n",
+ "s3=s1+s2 \n",
+ "#Result\n",
+ "print \"Concatenated String: \", s1+s2"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter String One: venkat\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter String two: raman\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Concatenated String: venkatraman\n"
+ ]
+ }
+ ],
+ "prompt_number": 4
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 23: Page No. L.44"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#program to store and print same data to and from the file.\n",
+ "\n",
+ "#open file\n",
+ "fp=open(\"Text.txt\",\"w\")\n",
+ "\n",
+ "#User Input\n",
+ "c=raw_input(\"Enter the Text: \")\n",
+ "\n",
+ "#Store given input into a file \"text.txt\"\n",
+ "fp.write(c)\n",
+ "\n",
+ "#Closing file\n",
+ "fp.close()\n",
+ "\n",
+ "#Again open text.txt\n",
+ "fp=open(\"Text.txt\", \"r\")\n",
+ "\n",
+ "#display the content from the file \"text.txt\"\n",
+ "print \"Displaying text from file:\\n\",c \n",
+ "fp.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Text: VRB PUBLISHERS\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Displaying text from file:\n",
+ "VRB PUBLISHERS\n"
+ ]
+ }
+ ],
+ "prompt_number": 13
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 24: Page No. L.46"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program to count number of characters in a file.\n",
+ "\n",
+ "#create a file\n",
+ "fp=open(\"str.txt\",\"w\")\n",
+ "c=\"\"\n",
+ "print \"Enter the Characters:\"\n",
+ "print \"Press ctrl+z to stop entry\"\n",
+ "\n",
+ "#User Input\n",
+ "c=raw_input()\n",
+ "#store input into the file\n",
+ "fp.write(c)\n",
+ "fp.close()\n",
+ "\n",
+ "#Again open the file to read\n",
+ "fp=open(\"str.txt\",\"r\")\n",
+ "\n",
+ "#Result\n",
+ "print \"\\n%s\"%(c)\n",
+ "print \"Number of characters in the file: \",len(c)\n",
+ "fp.close()"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Enter the Characters:\n",
+ "Press ctrl+z to stop entry\n"
+ ]
+ },
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "vrb publishers private limited\n"
+ ]
+ },
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "\n",
+ "vrb publishers private limited\n",
+ "Number of characters in the file: 30\n"
+ ]
+ }
+ ],
+ "prompt_number": 23
+ },
+ {
+ "cell_type": "heading",
+ "level": 2,
+ "metadata": {},
+ "source": [
+ "Exercise 25: Page No.: L.48"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "collapsed": false,
+ "input": [
+ "#Program using Memory Allocation function\n",
+ "\n",
+ "NULL=0\n",
+ "buffer_size=10\n",
+ "\n",
+ "buffer1 = \"BOMBAY\"\n",
+ "print \"Buffer of size %d created\"%(buffer_size)\n",
+ "print \"Buffer contains\", buffer1\n",
+ " \n",
+ "\n",
+ "if buffer_size==NULL:\n",
+ " print \"Malloc failed\"\n",
+ " \n",
+ "else:\n",
+ " print \"Buffer size modified\"\n",
+ " print \"Buffer still contains:\", buffer1\n",
+ " \n",
+ "buffer1=\"MUMBAI\"\n",
+ "print \"Buffer now contains:\", buffer1"
+ ],
+ "language": "python",
+ "metadata": {},
+ "outputs": [
+ {
+ "output_type": "stream",
+ "stream": "stdout",
+ "text": [
+ "Buffer of size 10 created\n",
+ "Buffer contains BOMBAY\n",
+ "Buffer size modified\n",
+ "Buffer still contains: BOMBAY\n",
+ "Buffer now contains: MUMBAI\n"
+ ]
+ }
+ ],
+ "prompt_number": 19
+ }
+ ],
+ "metadata": {}
+ }
+ ]
+} \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/README.txt b/Fundamental_of_Computing_and_Programming_in_C/README.txt
new file mode 100755
index 00000000..9bed1b50
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/README.txt
@@ -0,0 +1,10 @@
+Contributed By: Lakshmidharan D
+Course: msc
+College/Institute/Organization: Pachaiyappa's College for Men, Kanchipuram
+Department/Designation: Computer Science
+Book Title: Fundamental of Computing and Programming in C
+Author: V. Ramesh Babu, R. Samyuktha, M. Munirathnam
+Publisher: Lakshmidharan D
+Year of publication: 2012
+Isbn: 9789381837214
+Edition: August 2012 \ No newline at end of file
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Calculation.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Calculation.png
new file mode 100755
index 00000000..54b0ef8a
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Calculation.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even.png
new file mode 100755
index 00000000..ba866766
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_1.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_1.png
new file mode 100755
index 00000000..ba866766
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_1.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_2.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_2.png
new file mode 100755
index 00000000..ba866766
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_2.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_3.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_3.png
new file mode 100755
index 00000000..ba866766
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Decision_Making_Odd_or_Even_3.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line.png
new file mode 100755
index 00000000..19625214
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_1.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_1.png
new file mode 100755
index 00000000..19625214
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_1.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_2.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_2.png
new file mode 100755
index 00000000..19625214
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_2.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_3.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_3.png
new file mode 100755
index 00000000..19625214
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_3.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_4.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_4.png
new file mode 100755
index 00000000..19625214
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Slope_and_Midpoint_of_a_line_4.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Standard_Deviation.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Standard_Deviation.png
new file mode 100755
index 00000000..a448529e
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Standard_Deviation.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi.png
new file mode 100755
index 00000000..88aee856
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi_1.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi_1.png
new file mode 100755
index 00000000..88aee856
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/Tower_of_Honoi_1.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers.png
new file mode 100755
index 00000000..05bef403
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers.png
Binary files differ
diff --git a/Fundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers_with_A.png b/Fundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers_with_A.png
new file mode 100755
index 00000000..2c6a1efe
--- /dev/null
+++ b/Fundamental_of_Computing_and_Programming_in_C/screenshots/add_two_numbers_with_A.png
Binary files differ