summaryrefslogtreecommitdiff
path: root/Fundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb
diff options
context:
space:
mode:
authorhardythe12015-04-07 15:58:05 +0530
committerhardythe12015-04-07 15:58:05 +0530
commit92cca121f959c6616e3da431c1e2d23c4fa5e886 (patch)
tree205e68d0ce598ac5caca7de839a2934d746cce86 /Fundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb
parentb14c13fcc6bb6d01c468805d612acb353ec168ac (diff)
downloadPython-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.gz
Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.tar.bz2
Python-Textbook-Companions-92cca121f959c6616e3da431c1e2d23c4fa5e886.zip
added books
Diffstat (limited to 'Fundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb')
-rwxr-xr-xFundamental_of_Computing_and_Programming_in_C/Chapter21.ipynb174
1 files changed, 174 insertions, 0 deletions
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