From 92cca121f959c6616e3da431c1e2d23c4fa5e886 Mon Sep 17 00:00:00 2001 From: hardythe1 Date: Tue, 7 Apr 2015 15:58:05 +0530 Subject: added books --- .../Chapter5.ipynb | 475 +++++++++++++++++++++ 1 file changed, 475 insertions(+) create mode 100755 C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb (limited to 'C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb') diff --git a/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb b/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb new file mode 100755 index 00000000..ac86dba8 --- /dev/null +++ b/C_Programming_for_the_Absolute_Beginner/Chapter5.ipynb @@ -0,0 +1,475 @@ +{ + "metadata": { + "name": "", + "signature": "sha256:22dbf664bff583df60a7371a6f741be85c976f32fe9bef5f00f146ca5848d933" + }, + "nbformat": 3, + "nbformat_minor": 0, + "worksheets": [ + { + "cells": [ + { + "cell_type": "heading", + "level": 1, + "metadata": {}, + "source": [ + "Chapter 5 : Structured Programming" + ] + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.1, Page No 116" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def addTwoNumbers(operand1,operand2):\n", + " return operand1+operand2\n", + "\n", + "print \"Nothing happenning here\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Nothing happenning here\n" + ] + } + ], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.2, Page No 118" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def addTwoNumbers(num1,num2):\n", + " return num1+num2\n", + "\n", + "def subtractTwoNumber(num1,num2):\n", + " return num1-num2\n", + "\n", + "print \"Nothing happenning here\"" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Nothing happenning here\n" + ] + } + ], + "prompt_number": 3 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.3, Page No 119" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def addTwoNumbers(operand1,operand2):\n", + " return operand1+operand2\n", + "\n", + "\n", + "iResult= addTwoNumbers(5,5)" + ], + "language": "python", + "metadata": {}, + "outputs": [], + "prompt_number": 1 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.4, Page No 120" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def addTwoNumbers(operand1,operand2):\n", + " return operand1+operand2\n", + "\n", + "print \"The result is : \",addTwoNumbers(5,5)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The result is : 10\n" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.5, Page No 120" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def addTwoNumbers(operand1,operand2):\n", + " return operand1+operand2\n", + "\n", + "num1=int(raw_input(\"Enter the first number: \"))\n", + "num2=int(raw_input(\"Enter the second number: \"))\n", + "print \"The result is: \",addTwoNumbers(num1,num2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the first number: 57\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter the second number: 43\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "The result is: 100\n" + ] + } + ], + "prompt_number": 9 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.6, Page No 121" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def printReportHeader():\n", + " print \"\\n Column1 \\t Column2 \\t Column3 \\t Column4 \\n\"\n", + " \n", + "printReportHeader()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "\n", + " Column1 \t Column2 \t Column3 \t Column4 \n", + "\n" + ] + } + ], + "prompt_number": 11 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.7, Page No 122" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "num1=int(raw_input(\"Enter a number: \"))\n", + "print \"You entered \",num1" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a number: 10\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "You entered 10\n" + ] + } + ], + "prompt_number": 12 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.8, Page No 123" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "def getSecondNumber():\n", + " num1=int(raw_input(\"Enter Second number: \"))\n", + " return num1\n", + "\n", + "num1=int(raw_input(\"Enter a number: \"))\n", + "num2=getSecondNumber()\n", + "print \"you entered \"+str(num1)+\" and \",str(num2)" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter a number: 28\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter Second number: 35\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "you entered 28 and 35\n" + ] + } + ], + "prompt_number": 17 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.9, Page No 124" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "iLuckyNumber=int()\n", + "def printLuckyNumber():\n", + " print \"Your lucky number is: \",iLuckyNumber\n", + "\n", + "\n", + "iLuckyNumber=int(raw_input(\"Enter your lucky number: \"))\n", + "printLuckyNumber()" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "stream": "stdout", + "text": [ + "Enter your lucky number: 10\n" + ] + }, + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "Your lucky number is: 10\n" + ] + } + ], + "prompt_number": 19 + }, + { + "cell_type": "heading", + "level": 2, + "metadata": {}, + "source": [ + "Example 5.10, Page No 126" + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "import os\n", + "import time\n", + "def sportsQuestion():\n", + " print \"Sports Question\"\n", + " print \"What University did NFL star Deon Sanders attend?\"\n", + " print \"1 \\t University of Miami\"\n", + " print \"2 \\t California State University\"\n", + " print \"3 \\t Indiana University\"\n", + " print \"4 \\t Florida State University\"\n", + " iAnswer=int(raw_input(\"Enter your selection :\"))\n", + " return iAnswer\n", + "\n", + "def geographyQuestion():\n", + " print \"Geography Question\"\n", + " print \"What is the state capitol of Florida?\"\n", + " print \"1 \\t Pensecola\"\n", + " print \"2 \\t Tallahassee\"\n", + " print \"3 \\t Jacksonville\"\n", + " print \"4 \\t Miami\"\n", + " iAnswer=int(raw_input(\"Enter your selection :\"))\n", + " return iAnswer\n", + "def pause(inNum):\n", + " iCurrentTime=0\n", + " iElapsedTime=0\n", + " \n", + " iCurrentTime=int(round(time.time()*1000))\n", + " \n", + " while((iElapsedTime-iCurrentTime)