Assignment 2: Use Arrays To Structure The Raw Data and To Perform Data Comparison & Operations
Assignment 2: Use Arrays To Structure The Raw Data and To Perform Data Comparison & Operations
Use arrays to structure the raw data and to perform data comparison &
operations
Write a program which creates an integer array and displays sum of its
elements.
Use arrays to structure the raw data and to perform data comparison &
operations
Write a program which performs addition of elements which are stored in two
arrays of type double.
Arrays lengths may be variable in size. The resultant values must be stored in
an integer array. Display the resultant integer array in a formatted way.
Example:
Input:
Output:
10 70 60 70 80
iSumArray[]
Use arrays to structure the raw data and to perform data comparison &
operations
Write a method that receives a name as parameter and prints on the console.
“Hello, <name>!” Example
Input Output
Peter Hello, Peter!
Use arrays to structure the raw data and to perform data comparison &
operations
Create a method GetMax(int a, int b, int c), that returns maximal of three
numbers. Write a program that reads three numbers from the console and
prints the biggest of them.
Examples
Input Output Input Output
1 3 -100 -100
2 -101
3 -102
Use arrays to structure the raw data and to perform data comparison &
operations
Use arrays to structure the raw data and to perform data comparison &
operations
n IsPrime(n)
0 false
1 false
2 true
3 true
4 false
5 true
323 false
337 true
6737626471 true
117342557809 false
Use arrays to structure the raw data and to perform data comparison &
operations
Write a method that calculates all prime numbers in given range and
returns them as list of integers
Write a method to print a list of integers. Write a program that takes two
integer numbers (each at a separate line) and prints all primes in their range,
separated by a comma.
Examples
Start and End Output
Number
0
2, 3, 5, 7
10
5
5, 7, 11
11
100 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167,
200 173, 179, 181, 191, 193, 197, 199
250 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331,
950 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419,
421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499,
503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599,
601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677,
683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773,
787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877,
881, 883, 887, 907, 911, 919, 929, 937, 941, 947
100
(empty list)
50
Use arrays to structure the raw data and to perform data comparison &
operations
Write a program that can calculate the area of four different geometry figures
- triangle, square, rectangle and circle.
On the first line you will get the figure type. Next you will get parameters
for the chosen figure, each on a different line:
• Triangle - side and height
• Square - side
• Rectangle - width and height
• Circle - radius
Use arrays to structure the raw data and to perform data comparison &
operations
Write a method which accepts two integer arrays and returns an array of
unique elements.
Example:
Array 1 = { 10, 5, 20, 15, 25, 30}
Array 2 = {50, 12, 5, 30, 15, 70}
Result_Array = {10, 20, 25, 50, 12, 70}
Use arrays to structure the raw data and to perform data comparison &
operations
Use arrays to structure the raw data and to perform data comparison &
operations