summaryrefslogtreecommitdiff
path: root/Programming_With_C_by_Byron_S._Gottfried/chapter3.ipynb
blob: fbf10f109a84a488d6b49f5877bd8d8023f804db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
{
 "metadata": {
  "name": ""
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h1>Chapter 3: Operators and Expressions<h1>"
     ]
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3.13, Page number: 3.9 <h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "import ctypes as ct\n",
      "\n",
      "print \"interger  : \",ct.sizeof(ct.c_int())\n",
      "print \"float     : \",ct.sizeof(ct.c_float())\n",
      "print \"double    : \",ct.sizeof(ct.c_double())\n",
      "print \"character : \",ct.sizeof(ct.c_char())\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "interger  :  4\n",
        "float     :  4\n",
        "double    :  8\n",
        "character :  1\n"
       ]
      }
     ],
     "prompt_number": 1
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3.30, Page number: 3.19<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "print \"for the equation ax^2+bx+c \\n\"\n",
      "\n",
      "a=2\n",
      "b=6\n",
      "c=3\n",
      "\n",
      "root=(b*b-4*a*c)**0.5\n",
      "x1=(-b + root)/(2*a)\n",
      "x2=(-b - root)/(2*a)\n",
      "\n",
      "print \"x1=\",x1\n",
      "print \"x2=\",x2\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "for the equation ax^2+bx+c \n",
        "\n",
        "x1= -0.633974596216\n",
        "x2= -2.36602540378\n"
       ]
      }
     ],
     "prompt_number": 3
    },
    {
     "cell_type": "markdown",
     "metadata": {},
     "source": [
      "<h3>Example 3.31, Page number: 3.20<h3>"
     ]
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "\n",
      "\n",
      "\n",
      "lower=\"l\"\n",
      "upper=lower.upper()\n",
      "print upper\n",
      "\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "L\n"
       ]
      }
     ],
     "prompt_number": 2
    }
   ],
   "metadata": {}
  }
 ]
}