Some Questions on Array

1.  Accept 10 numbers into an array and display all those numbers.

2.  Accept 10 numbers into an array A. Then display the array in reverse form.

3.  Accept 10 numbers into an array and then calculate the sum of numbers present in odd positions and even positions respectively.

4.  Accept 10 numbers into an array and then calculate the sum of even numbers present in odd positions.

5.  Create an array of size 10. Automatically fill the array with the factorial of number between 1 to 10, and then display the content of array.

6.  Create three arrays A, B and C both of size 5. Accept numbers in two arrays A and B. Fill all the elements of array C with the sum of numbers present in appropriate element of array A and B.

7.  Create two arrays A and B of size 5 and C of size 10. Accept numbers in two arrays A and B. Fill the array C in such a way that the first five positions occupy the numbers present in array A and rest of five positions occupy the numbers present in array B.

8.  Create two arrays A and B of size 5 and C of size 10. Accept numbers in two arrays A and B. Fill the array C in such a way that the all odd positions occupy the numbers present in array A and all even positions occupy the numbers present in array B.

9.  Accept numbers into an array A of size 10 and create another array B of size 5. The array B first location fills with sum of first and second location of array A. The array B second location fills with sum of third and forth location of array A. Similarly fill all the position of array B & display it.

10. Write a program to sort an array of size 10.

11. Create a list of names of 25 friends and then display friend�s name alphabetically.

12. Accept the name, physics, chemistry and math marks of 25 students. The display a list of the given data with Total and Average.

13. Accept the name and total marks of 15 students. Then display the list according to their merit.

14. Accept numbers into an array of size 10. Then accept a number and search that number in array. If the number is present in array, then display the array element number where number is found. In case of multiple found display all the positions. Display a proper message if the number is not present in array.

15. Create an array of size 10 then accept 9 numbers into it. Then accept another number and its position where you want to insert it. Insert the given number in given position then Display the array.

16. Accept 10 numbers into an array. Then accept a position number and delete the number present in that position.

17. (a) Accept data into two integer array A & B of size 5 elements each. The program should create another array T that finds the intersection of the two arrays.

    For e.g. if A = {1,3,5,7,8} & B = {7,4,2,8,9}   Then T = {7, 8}

17. (b) Accept data into two integer array A & B of size 5 elements each. The program should create another array T that finds the union of the two arrays.

    For e.g. if A = {1,3,5,7,8} & B = {7,4,2,8,9}   Then T = {1,3,5,4,2,9}

18. Accept numbers into an integer array A of size 4, create another string array B of size 3. Accept any three mathematical symbol like (+, -, *, /) in array B. Then according to mathematical symbol calculate the answer.

        For e.g. if A=[8, 6, 4, 2] & B=[+, -, *], then answer will be (((8+6)-4)*2) = 20

19. Store three numbers in an array. Write a program in BASIC to create another array, which has the squared elements in the first array and also print the created array.

20. Write a program in BASIC to taken as input from user by using a single subscripted variable, the marks in computer science of forty students and then print those marks in descending order in a column.

21. Developed a BASIC program to accept the temperature of any 10 cities in degrees Fahrenheit through INPUT statement. Convert temperature to degree centigrade using the given formula:

        Centigrade = (Fahrenheit - 32) X 5/9

    Display the information in the given format. Also at the end print the total number of cities where the temperature is more then 35 degree centigrade and the city name with maximum temperature.

Name of the

cities

Fahrenheit

Temperature

Centigrade

Temperature

--

--

--

--

--

--

--

--

--

--

--

--

    Number of cities more then 35-degree centigrade temperature:

    Name of the city with maximum temperature:

22. Write a program in BASIC that reads the following list of countries and their respective cities into two separate one-dimensional arrays. The program should accept the name of a country in the list as input and give the name of the corresponding city as an output. The program should be designed to give an error message where a city is asked for a country whose name is not given in the list. To stop the program, �XXX� is to be entered as input.

            GERMANY         BERLIN

            NEPAL           KATMANDU

            JAPAN           TOKYO

            CANADA          MONTREAL

            IRAQ            BAGHDAD

            SRI LANKA       COLOMBO

            BRAZIL          BRAZILIA

            AUSTRALIA       PERTH

            INDIA           DELHI

            SOUTH AFRICA    PRETORIA

23. There are 100 elements in an array A$, Write a program in BASIC to arrange first 50 elements of the array in ascending order and rest 50 elements into descending order.

24. Write a program in BASIC to store 20 names, address and phone number in three separate arrays. Depending on the user�s choice either locates name or phone number and prints all the information.

25. A metropolitan hotel has ten floors numbered from 1 to 10, each floor having fifty rooms. Using a single subscripted variables for the name of the customer and a double subscripted variable R(F,I) where F & I represents floor and room numbers. Write a program for the room allocation work. The program should automatically display the name of the customer, room and floor number.

26. Write a program in basic to stores names of the 10 politician and their party to which they belong to in two separate arrays. Ask the users to enter the name of the party. Printout all the names of the politicians who belong to that party. Repeat the process according to user choice.

27. Write a program in basic to open 3 arrays of name A, P & N. Store 15 numbers in array A. Shift all the positive even numbers in array P and all the negative odd numbers in array N. Finally print the array P & N.

28. Accept numbers into an array of size 3X4. Then display the array properly.

29. Accept numbers into an array of size 4X4. Then display the diagonals and also display the sum of numbers present in the diagonal position.

30. Write a program to accept number into a 3X4 matrix. Display the original array. Then calculate and display the row total.

31. Write a program to accept number into a 3X4 matrix. Display the original array. Then calculate and display the column total.

32. Write a program to accept number into a 10X5 matrix. Then display the original array and the array sorted on each column.

33. Accept numbers into an array of size 5X5. Then display the numbers present in upper portion of the left diagonal of the matrix.

34. Accept numbers into an array of size 5X5. Then display the numbers present in below portion of the left diagonal of the matrix.

35. Write a program to accept numbers into a 4X3 matrix. Display the original matrix and display the matrix in transpose form.

36. Write a program to create a two dimensional array of 3X3 size and store number in it. Add two to all numbers and transfer it to another array.

37. Write a program to accept number in two 3X4 array and then find their sum as another 3X4 array.

38. Using a double subscripted variables, Write a program in BASIC to enter data to form 6X7 array and get a printout as follows:

SUN

MON

TUE

WED

THU

FRI

SAT

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

 

39. Two matrices A and B are given as:

        9   7    13            8   7    9

    A = 6   12   18        B = 3   11   15

        5   10   15            2   9    14

    Write a BASIC program to compute and print D

    Where D = Sum of left diagonal of array A

              Sum of right diagonal of array B

40. The values of three matrices are given below. Calculate and store the sum of all the elements in another matrix S. Finally print the matrix S.

        2     9        1    2         15     2

    X=  4     9     Y= 5    4      Z= 20     9

        6     10       9    3         13     10

41. A Company produce ten different products A1,A2,........ A10 with P1,P2,...........P10 as the price per unit and Q1,Q2,......Q10 as the quantities produced respectively. Write a program to store the data in 10 X 2 matrix M as cost per unit and Quantity. Calculate and print the total cost of material produced.

42. Write a program in BASIC to input data into array A(3,3) and B(3,3) and then find the product of two arrays in an array C(3,3) which is obtained by the logic.

    C(1,1) = A(1,1)*B(1,1) + A(1,2)*B(2,1) + A(1,3)*B(3,1)

43. Write a program to find from the following data: 17, 20, 24, 29, 16, 87, 19, 52

    a) The largest and smallest element b) Product of the odd numbers c) sum of the even numbers

44. A company produces ten items and sales them at definite prices. The details of sales of each product are recorded month wise from January to December. Writes a program to find: The annual sale of each product and the total amount sale of all products.

45. Write a program to generate a Pascal triangle in which each number in the row is the sum of the two numbers immediately above it. The program should print the first six rows of the triangle.

    (Hints: E[J,I] = P[I-1,J-1] + P[I-1,J] is true for all elements but the boundary elements which are all equal to 1)