Chapter 1: Getting Started

First C Program, Page number: 14

In [1]:
p = 1000 #principle
n = 3 # number of years
r = 8.5 # rate of interest

#Calculation
si = p * n * r / 100 ; #formula for simple interest

#Result
print ( si )
255.0

Simple Interest, Page number: 21

In [2]:
p = 100 # principle
n = 5 # number of years
r = 15.5 # rate of interest

#Calculation
si = p * n * r / 100 ; #formula for simple interest

#Result
print ( si )
77.5

Just for fun, Page number: 22

In [4]:
num = 11

#Result
print  "Now I am letting you on a secret..."  
print "You have just entered the number", num 
Now I am letting you on a secret...
You have just entered the number 11

Example 1.1, Page number: 32

In [2]:
i1 = 2 * 3 # operation *
i2 = i1 / 4 # operation /
i3 = 4 / 4 # operation /
i4 = 5 / 8 # operation /
i5 = i2 + i3 # operation +
i6 = i5 + 8 # operation +
i7 = i6 - 2 # operation -
i8 = i7 + i4 # operation +
i = i8

#Result
print "i = ", i
i =  8

Example 1.2, Page number: 33

In [3]:
kk1 = 3 / 2# operation /
kk2 = kk1 * 4 # operation *
kk3 = 3 / 8 # operation /
kk4 = kk2 + kk3 # operation +
kk5 = kk4 + 3 # operation +
kk = kk5

#Result
print "kk = ", kk
kk =  7
In [ ]: