You are on page 1of 14

Answer for Chapter 1 Exercises

1. C) A Series of instructions that tell computer hardware how to perform tasks.

2. C) Storage Device

3. A) Temporary, Volatile

4. C) System Software

5. D) Pascal

6. C) Binary Numbers

7. B) Integrated Development Environment

8. A) Pseudocode, Flowchart

9. C) Program Development Life Cycle, five

10. B) Sequential, Selection, Repetition

1) For a) Output : Volume


Input : 1/3, Pi, pow (radius, 2), height,
radius, height
Process : Volume = 1/3 * Pi * pow (radius, 2) * height
double volume, radius, height
const double pi= 3.142;
Volume = 1/3.0*pi*pow(radius,2)*height
b) Output : f
frequency
Input : 2.0, 0.6
speed=2.0, wavelength=
Process : double frequency, speed, wavelength
Frequency = speed/wavelength

c) Output : “EVEN” or “ODD”


Input : num
number
Process : (if num = num1, num3, num5, num7, num9)
YES (odd)
NO (even)
int number
if (number%2==0)
display “EVEN”
else
display “ODD”

d) Output : int ply; double height


totHeight
Input : height
Process : ply++ = height
double totHeight=0, height
for(int player=1;player <=10;player++)
input height
totHeight=totHeight + height;
display totHeigth

2) a) BEGIN
DECLARE char Name [50]; double Hours, Rate, Pay
INPUT Name, Hours, Rate
CALCULATE Pay = Hours * Rate
DISPLAY Name, Pay
END

b) BEGIN
DECLARE int emp=1, total=0; double salary
while (emp<= 10)
GET salary
CALCULATE total=total+salary, emp=emp+1
PRINT total
END
3) a) START

DECLARE int base=4, height; double area

GET

height

COMPUTE area=0.5*base*height

PRINT

base, height, area

END
b) START

DECLARE double p, m, v

INITIALIZE

m=1.50, v=4

CALCULATE p= m*v

DISPLAY

END
START
4)

DECLARE int weight double radius, height, density=0.284, weight;

int steel=1; const double PI=3.142

while (steel<=5)

GET radius, height


TRUE
FALSE

CALCULATE weight=density*Pi*pow(radius, 2)*height

steel++

DISPLAY

weight

END
5) BEGIN
DECLARE double monthPay, timePeriod, loanAmount,
interest=0.05, totInterest, totLoan
GET loanAmount, timePeriod
CALCULATE
totInterest= (loanAmount*timePeriod)*interest;
monthPay= (loanAmount+totInterest)/(timePeriod*12);
DISPLAY monthPay
END

START

DECLARE double monthPay, timePeriod, loanAmount, interest=0.05, totInterest, totLoan;

GET loanAmount, timePeriod

CALCULATE totInterest=(loanAmount*timePeriod)*interest;

monthPay=(loanAmount+totInterest)(timePeriod*12)

DISPLAY monthPay

END
6) BEGIN
DECLARE double length=9, width=4.5, height=5, mass=1800, density, volume
CALCULATE
volume=lenght*width*height;
density=mass/volume
DISPLAY density
END

START

DECLARE double length=9, width=4.5, height=5, mass=1800, density, volume

CALCULATE

volume=length*width*height

density=mass/volume

DISPLAY density

END
7)

START

DECLARE double mass=850, acc=2, force

CALCULATE

force=mass*acc

DISPLAY force

END
8)

START

DECLARE int age

GET age

TRUE
If (age<=12) DISPLAY child

FALSE

DISPLAY “ADULT”

END
9) BEGIN
DECLARE double area, length, width; int rec=1
while (rec<=10)
GET length, width
CALCULATE area=length*width, rec++
DISPLAY area
END

10)
START

DECLARE double voltage, current=5, resistance=7

CALCULATE

voltage=current*resistance

DISPLAY voltage

END
DISCUSSION QUESTIONS
START
1. BEGIN
DECLARE double h, p, d; const int ATM=101325
const double G=9.81
GET h, d DECLARE double h, p, d; const int ATM=101325
CALCULATE p=ATM+h*d*G
DISPLAY p const double G=9.81
END

Output
pressure GET h, d
Input
height, density
Process
const double GRAVITY=9.81
CALCULATE
const double ATM=101325
double pressure, height, density p=ATM+h*d*G
pressure=ATM+height*density*GRAVITY

DISPLAY p

END

2. BEGIN
DECLARE double u=40, v=30, s=70, acc
CALCULATE acc = (pow(u,2) – pow (v,2)) / (2*s)
DISPLAY acc
END

Output
acc
Input
u=40, v=30, s=70
Process
double acc, u=40, v=30, s=70
acc= (pow(u,2) – pow (v,2)) / (2*s)
START

DECLARE double u=40, v=30, s=70

CALCULATE

acc= (pow(u,2) – pow (v,2)) / (2*s)

DISPLAY acc

END
START

3. BEGIN
DECLARE double voltage, r , i ;
DECLARE double voltage, r, i
INITIALIZE r=2000, i =0.00175
CALCULATE voltage=i*r
DISPLAY voltage
END
INITIALIZE r=2, i=1.75
Output
voltage
Input
r=2000, i =0.00175 CALCULATE voltage=i*r
Process
double voltage, i , r
voltage=i*r

DISPLAY voltage

END

4.

START
Output Input Process

acc mass=100, force=500 double acc, mass, force


acc=mass/mass
DECLARE double acc, mass, force

BEGIN
DECLARE double acc, force, mass
INITIALIZE mass=100, force=500
INITIALIZE mass=100, force=500
CALCULATE acc=force/mass
DISPLAY acc
END
CALCULATE acc=force/mass

DISPLAY acc

END
5.

Output Input Process

speed f=35, Iam=0.7 double speed, f, Iam START


speed=f*Iam

BEGIN
DECLARE double speed, f, lam DECLARE double speed, f, Iam
INITIALIZE f=35, lam=0.7
CALCULATE speed=f*lam
DISPLAY speed
END
INITIALIZE f=35, Iam=0.7

CALCULATE speed=f*Iam

DISPLAY speed

END

You might also like