Вы находитесь на странице: 1из 10

Problem Solving

Tutorial 3
AAPP005-3-2
Offered In:
APIIT DIPLOMA IN COMPUTING AND IT
APIIT DIPLOMA IN BUSINESS WITH IT

Prepared by: JK First Prepared on: 01-07-04 Last Modified on: xx-xx-xx
Quality checked by: SVC
Copyright 2004 Asia Pacific Institute of Information Technology
Looping Constructs - Exercise

You are required to design a complete system


which will enable you to calculate the average for
a list of given values. The number of values to be
averaged should be specified by the user.

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 2 (of 10)
Looping Constructs - Exercise

You are required to design a complete system


which will allow you to calculate the factorial of n,
a value which is specified by the user.
For Example,

5! = 5 X 4 X 3 X 2 X 1 = 120

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 3 (of 10)
Looping Constructs - Exercise

You are required to design a computer system


which will enable the computer to display on the
screen a series of n odd numbers.

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 4 (of 10)
Looping Constructs - Exercise

You are required to design a complete system


which will allow you to calculate the result of n
raised to the power of p.

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 5 (of 10)
Looping Constructs - Exercise

You are required to design a complete system


which will enable you to read in a series of prices
of products purchased by a customer, to produce
the total price.
The system is then required to read in the amount
paid by the customer, followed by the balance to
be returned to the customer.

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 6 (of 10)
Nested Looping

Write an algorithm that will produce the following output:

Sample input:
How many lines of pattern would like to display: 4

Sample output:
1
22
333
4444

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 7 (of 10)
Nested Looping

Write an algorithm that will produce the following output:

Sample input:
How many lines of pattern would like to display: 4

Sample output:
/
//
/*/
/**/

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 8 (of 10)
Nested Looping

Write an algorithm that will produce the following output:

Sample input:
How many lines of pattern would like to display: 4

Sample output:
1
24
357
4682

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 9 (of 10)
Nested Looping

Write an algorithm that will produce the following output:

Sample input:
How many lines of pattern would like to display: 4

Sample output:
4444
333
22
1

AAPP005-3-2 Problem Solving & Program Design Using C Problem Solving Slide 10 (of 10)

Вам также может понравиться