by CodeChum Admin
Remember that time when we've tried identifying the largest digit among the given integer? Well, let's take it to the next level, and figure out the same thing on arrays/lists!
Let's do this one more time!
Instructions
Input
The first line contains the size of the array/list.
The next lines contains an integer on each.
5
5
34
3
23
10Output
A line containing an integer.
34by CodeChum Admin
Did you know that you can also reverse lists and group them according to your liking with proper code? Let's try it to believe it.
Instructions
Input
The first line contains an odd positive integer.
The next lines contains an integer.
5
1
3
4
5
2Output
A line containing a list.
[2,5]-[4]-[3,1]by CodeChum Admin
Let's try defining the size of the list and create the contents of it on our own! And then, to give off a sense of excitement, let's try accessing the value of a list element in a random index position!
Let's do this fast!
Input
The first line contains an integer n which is the size of the array.
The next n lines contains a string on each.
The last line contains an integer which is the index to be accessed and printed.
6
Learning
Programming
made
easy
with
Cody!
5Output
A line containing a string.
Cody!by CodeChum Admin
Counting off a list of decimal numbers is hard when you speak it, but not when you code it! Don't believe me? Then let's try coding just that!
Instructions
Output
Multiple lines containing a decimal number.
5.1
5.5
4.00001
4.024
3.0
3.66
2.5
2.2
1.2054
1.4by CodeChum Admin
You can also make a list of numbers, ey? Let's go and have some fun in tweaking the values of each element, but let's give it some twist to add on some fun to the code.
Let's have a go at it!
Instructions:
Instructions
Output
The squares and cubes of the elements in the array.
4
1
1
8
27
.
.
.by CodeChum Admin
Lists are fun to make, but it's even better to add or remove things from it when it's not usable anymore, right? Let's do just that in this problem now!
Instructions
Input
Two lines containing a string.
fun
PythonOutput
A line containing a string.
Python·is·really·funUsing any loop of your choice create a program that will prompts the user for two numbers and do calculations as follows, starting from the smallest number add the next number if its even or subtract it if its odd, repeat this until you get to the last number. i.e. if you start at 2 to 4, then 2 – 3 + 4( - because 3 is odd and + because 4 is even)
Parents of the pupils of the Park Primary School must pay an amount for outfits for the annual
play. All pupils take part in the play, except the Grade 0 pupils. The amount that the parents have
to pay is calculated as follows:
The cost of the outfits for Grade 1 and 2 pupils is R45.
The cost of the outfits for Grades 3 to 5 is R65.
Grade 6 and 7 pupils may play one or two roles. If they play a lead role, they may only play
one role. The cost of the outfits is R70 if they play one role. If this role is a lead role, the
cost is R100. If they play two roles, the cost is R130
Use a switch statement and write down ONLY the necessary C++ statements to
calculate and display the amount to be paid or display an appropriate error message if
required.
Do NOT write a complete program. Use the following
variables:
int grade;
int fee;
bool leadrole; //true if a child plays a lead role
bool roles2; //true if a child plays 2 roles
Parents of the pupils of the Park Primary School must pay an amount for outfits for the annual
play. All pupils take part in the play, except the Grade 0 pupils. The amount that the parents have
to pay is calculated as follows:
The cost of the outfits for Grade 1 and 2 pupils is R45.
The cost of the outfits for Grades 3 to 5 is R65.
Grade 6 and 7 pupils may play one or two roles. If they play a lead role, they may only play
one role. The cost of the outfits is R70 if they play one role. If this role is a lead role, the
cost is R100. If they play two roles, the cost is R130.