0% found this document useful (0 votes)
34 views2 pages

Exercises On Array Exercise 1: TH TH

This document provides 4 exercises on working with arrays in VB.net. The first exercise has the user declare an array to print the number, square and cube tables up to 15. It then asks the user to compute properties of these tables like the sum of squares and cubes. The second exercise has the user accept an integer n, declare an array of size n and randomly generate values to display and analyze the array. The third exercise has the user compute and display a profit table for shirt prices from $10 to $30. The fourth exercise introduces the Fibonacci sequence and has the user generate an array of Fibonacci numbers up to a given n, and then perform computations on this array.

Uploaded by

CORINE NDLOVU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views2 pages

Exercises On Array Exercise 1: TH TH

This document provides 4 exercises on working with arrays in VB.net. The first exercise has the user declare an array to print the number, square and cube tables up to 15. It then asks the user to compute properties of these tables like the sum of squares and cubes. The second exercise has the user accept an integer n, declare an array of size n and randomly generate values to display and analyze the array. The third exercise has the user compute and display a profit table for shirt prices from $10 to $30. The fourth exercise introduces the Fibonacci sequence and has the user generate an array of Fibonacci numbers up to a given n, and then perform computations on this array.

Uploaded by

CORINE NDLOVU
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercises on Array

Exercise 1
Write a program that will declare an array, print the number, squares and cubes table as shown below
using list box(es) and then compute the following with appropriate message description:

 The sum of the squares


 The sum of the cubes
 How many cubes were greater than 500
 A message stating whether or not the sum of the squares exceeded 2,000

NUMBER SQUARE CUBE


1 1 1
2 4 8
3 9 27
: : :
15 225 3375

Exercise 2
Write a VB.net program that will accept an integer value n and declare an array of nth term. The
program will then randomly generate integer number value to the nth term of the array.

1. Display the set of data in an array form in GUI


2. Display same data in a reverse order
3. Display the sorted array (avoid using the array.sort)
4. Compute and display the sum of the values in the original array
5. Compute and display the mean of the array
6. Compute and display the median of the original array
7. Compute and display the difference
8. Compute assumed median array of the original array.
9. Compute assumed cumulative array of the original array.

Exercise 3
A retail store has just received a new supply if shirts. The market preliminary market research
indicates the market profit obtainable a given price x is given by:
Profit = x(100 – 3x) Write a program to compute the following tabular profit output for the integer
sales of price ranging from R10 – R30

Price Profit
10 700
11 737
: :
: :
30 300

* What is the average profit?


* At which price did the profit starts falling?
Exercise 4
The Fibonacci numbers are a famous sequence of numbers. The first and the second are both 1.
Thereafter, the subsequence number is the sum of the previous two Fibonacci numbers.

Fib1 = 1, fib2 =1 fibn = fib(n-1) + fib(n-2)

Hence the first 12 positive Fibonacci numbers are:

1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144

Write a VB.net program to accept an n th integer value. Thereafter, generate an array of Fibonacci
number to the nth value. Compute the values of the queries that follow:
1. Display the set of data in an array form in GUI
2. Display same data in a reverse order
3. Display the square array of the fibo series
4. Compute and display the sum of the values in the fibo array
5. Compute and display the mean of the fibo array
6. Compute and display the median of the fibo array
7. Compute and display the difference of the fibo array
8. Computer and display assumed mean array of fibo series
9. Computer and display cumulative array of fibo series

You might also like