Uploaded by Azariah Rei

CSS122 PROBLEMS1-17

advertisement
CSS122 – AM1/AM3/AM5
MODULE 1 PROGRAMS
Given the array of fruits
0
1
2
3
Display the content of fruit array on
screen.
/mnbautista
4
Given the array of fruits
0
1
2
3
4
0
1
2
3
4
Ask the user to enter 5 grade scores for
the subject Advance Programming and
store it in an array named grade[]. The
program will compute and display the
average of 5 grade scores.
/mnbautista
====================
Advanced Programming
====================
Enter score [1]: 80
Enter score [2]: 80
Enter score [3]: 80
Enter score [4]: 80
Enter score [5]: 80
Average is 80.
/mnbautista
Given the array of friends
0
1
2
3
4
Write a program that will ask the user to
enter his/her friend’s name and display if
it
can
be
found
in
the
friendlist.
/mnbautista
====================
Good Friend Check
====================
Enter the name of your friend: May
I’m sorry your friend’s name is not in the list.
====================
Good Friend Check
====================
Enter the name of your friend: ina =
Hurray! Your friend is in the list.
/mnbautista
Write a program that will ask the user
what are his/her five wishes for Christmas
and store it into an array mywishlist[]. Your
program will copy these wishes to
another array youwishlist[] and display
the contents of two arrays on the screen.
/mnbautista
====================
5 Wishes on Christmas
====================
Enter your 1st wish: doll
Enter your 2 wish: clothes
Enter your 3rd wish: slippers
Enter your 4th wish: mug
Enter your 5th wish: umbrella
/mnbautista
Your five wishes are doll, clothes, slippers, mug and
umbrella.
My five wishes are doll, clothes, slippers, mug and
umbrella.
/mnbautista
Write a program that will enter 5 integer
numbers and determine the maximum
and minimum numbers.
/mnbautista
====================
Maximum and Minimum
====================
Enter your 1st number: 100
Enter your 2nd number : 50
Enter your 3rd number : 0
Enter your 4th number : 4
Enter your 5th number : 20
The minimum number is 0 and the maximum number is
100.
/mnbautista
Given the array of English Alphabet (from
A to Z). Write a program that will ask the
user which letter he/she wanted to
delete from the list. Display the array of
English Alphabet without the deleted
character/letter
/mnbautista
====================
English Alphabet
====================
Enter letter to be deleted: e
A B C D F G.. Z
Note: The user may enter either capital or small letter.
/mnbautista
0
1
2
3
4
Sort the given array using Bubble Sort
algorithm and use functions such
swap()-with parameter passing
display()
/mnbautista
A company has two stores (1 and 2), and
each store sells three items (1, 2, and 3).
The following tables give the inventory at
the beginning of the day and the
amount of each item sold during the
day.
/mnbautista
Create A function that counts the
number of times A particular letter shows
up in an array.
/mnbautista
/mnbautista
Beginning Inventory
ITEM
STORE NAME
1
2
3
STORE 1
25
64
23
STORE 2
12
82
19
Sale for Day
ITEM
/mnbautista
STORE NAME
1
2
3
STORE 1
7
45
11
STORE 2
4
24
8
Requirements:
1. Record the values of each table in an array.
2. Adjust the values in the first array to hold the
inventories at the end of the day and display
these new inventories.
3. Calculate and display the total number of items
in the store at the end of the day.
/mnbautista
/mnbautista
Table 1.2 gives the results of a survey on
the uses of computers in the workplace.
Each entry shows the percentage of
respondents from the educational
attainment category that use the
computer or the indicated purpose.
/mnbautista
1. Place the data from the table in an
array.
2. Determine the average of the
percentages in the Databases
column.
/mnbautista
Table1.2
SOFTWARE
Educational
Attainment
Word Processing
Spreadsheets
Databases
Communications
Desktop
Publishing
Not a HS
graduate
54.4
22.2
9.9
20.4
20.6
HS graduate
52.5
25.8
13.3
29.4
17.6
Some college
49.5
33.9
20.6
38.5
18.0
Four years of
college
40.0
41.5
28.8
45.1
17.0
More than four
years of college
29.3
41.9
35.3
48.5
10.4
/mnbautista
Table1.2
SOFTWARE
Educational
Attainment
Word Processing
Spreadsheets
Databases
Communications
Desktop
Publishing
Not a HS
graduate
54.4
22.2
9.9
20.4
20.6
HS graduate
52.5
25.8
13.3
29.4
17.6
Some college
49.5
33.9
20.6
38.5
18.0
Four years of
college
40.0
41.5
28.8
45.1
17.0
More than four
years of college
29.3
41.9
35.3
48.5
10.4
45.14
33.06
21.58
36.38
16.72
AVERAGE
/mnbautista
A company has three stores (1,2, and 3),
and each store sells five items (1,2,3,4
and 5). The following tables give the
number of items sold by each store and
category on a particular day, and the
cost of each item.
/mnbautista
1. Place the data from the left-hand
table in a two-dimensional array and
the data from the right-hand table in a
one-dimensional array.
2. Compute and display the total dollar
amount of sales for each store and for
the
entire
company.
/mnbautista
NUMBER OF ITEMS SOLD DURING THE DAY
COST PER ITEM
ITEM
ITEM
COST
1
2
3
4
5
1
$12.00
STORE 1
25
64
23
45
14
2
$17.95
STORE 2
12
82
19
34
63
3
$95.00
STORE 3
54
22
17
43
35
4
$86.50
5
$78.00
/mnbautista
JKL’s SALES REPORT
ITEM
STORE NAME
/mnbautista
1
2
3
4
5
STORE 1
300
1148.8
2185.0
3892.5
1092
STORE 2
144
1471.9
1805.0
2941.0
4914
STORE 3
648
394.9
1615.0
3354.0
2730
Write a program that will ask the user to enter 5
integer numbers and store it to 5 variables
num1, num2, num3, num4, and num5.
Use the following pointer variables to store the
addresses and/or access the values of the 5
numbers entered: ptrnum1, ptrnum2, ptrnum3,
ptrnum4 and ptrnum5.
/mnbautista
Use the sample input/
output as your guide:
Important:
No variables should be used
inside the executable area of
your program (only pointers).
Variables should be placed
only in the declaration and
initialization area.
/mnbautista
Write a program that will display the name
Diego A. Silang on the screen and replace it
with the name Gabriela C. Silang.
Use the following variables to store the firstname, middle
initial and last name of Diego: fName, mInitial, lName. In
addition, use the following pointer variables to store the
addresses and/or access the values: ptr_fName,
ptr_mInitial and ptr_lName.
/mnbautista
Use the sample
output as your guide:
Important:
No variables should be used
inside the executable area of
your program (only pointers).
Variables should be placed
only in the declaration and
initialization area.
/mnbautista
Write a program that will accept two numbers
from user and display the result of four basic
operation such as sum, difference, quotient
and product.
Use the following variables to store the 2 numbers and results: x, y,
sum, diff, pro, and quo.
Use the following pointer variables to store the addresses and/or
access the values of the 5 numbers entered: ptr_x, ptr_y, ptr_sum,
ptr_diff, ptr_pro and ptr_quo.
/mnbautista
Use the sample
output as your guide:
Important:
No variables should be used
inside the executable area of
your program (only pointers).
Variables should be placed
only in the declaration and
initialization area.
/mnbautista
Write a program that will accept three numbers
from user and display which among the three
numbers is the largest. Assume that values entered
are not the same and all are positive numbers.
Use the following variables to store the 2 numbers and results: num1,
num2, num3.
In addition, use the following pointer variables to store the
addresses and/or access the values: ptr_num1, ptr_num2 and
ptr_num3.
/mnbautista
Use the sample
output as your guide:
Important:
No variables should be used
inside the executable area of
your program (only pointers).
Variables should be placed
only in the declaration and
initialization area.
/mnbautista
Write a program that will accept a positive
integer number and display the next 10
consecutive numbers.
Use the following variables to store the positive number, the initial
counter and final counter of the loop: num, intCtr, finCtr.
In addition, use the following pointer variables to store the
addresses and/or access the values: ptr_num, ptr_intCtr, ptr_finCtr
/mnbautista
Use the sample
output as your guide:
Important:
No variables should be used inside the
executable area of your program (only
pointers).
Even counters in the loop should use
pointer variables.
Variables should be placed only in the
declaration and initialization area.
/mnbautista
Write a program that will accept two numbers
from user and display the result of four basic
operation such as sum, difference, quotient
and product.
Use the following variables to store the 2
numbers: x, y.
Use the given main function as your guide in writing
the required functions such as accepts(), sum(),
difference(), quotient, product().
/mnbautista
Write a program that will accept
two numbers from user and display
the result of four basic operations
such as sum, difference, quotient
and product.
Use the following variables to
store the 2 numbers: x, y.
Given the program segment, write the
required functions that will provide results
for 4 basic operations.
/mnbautista
Use the sample
output as your guide:
Important:
No variables should be used
inside the executable area of
your program (only pointers).
Variables should be placed
only in the declaration and
initialization area.
/mnbautista
Download