TOPIC ARRAYS
SUBMISSION DATE: - 28 -12-2010
VIVA IS CONDUCTED IN MY OFFICE ON TUESDAY (28-12-2010)
Q1: Write C++ statement to accomplish each of the following:
a) Display the value of the 7th element of character array F.
b) Input value into element 4 of single-subscripted floating point array B.
c) Initialize each of the 5 elements of single – subscripted integer array G to 8.
d) Total and print the floating point array C of 100 elements.
e) Copy array A into first portion of array B .assume float a[11], b[34];
f) Determine and print the smallest and largest value in 99 element floating point array W.
Q2) Make some simple modification in your Bubble Sort
a) After the first pass the largest number if guaranteed to be in the highest-numbered element of the array: after the second pass, the two highest numbers are “in place “so on. Instead of making nine comparisons of every pass, modify the bubble sort to make 8th comparisons on the second pass seven on the third pass and so on.
b) The data in array may be in proper order or near proper order so why will nine passes if fewer will suffice? Modify the sort to check at the end of each pass if any swap has been made. If none has been made then the data must already be in the proper order so the program should terminate, if swap have been made the at least one more pass is needed.
Q3) Write a single statements that perform the following single-subscripted
array operations
a) Initialize the 10 element of integer array counts to zeros
b) Add 1 to each of the 15 element of integer array bonus.
c) Read 12 values for float array monthlytemperatures from the keyboard
d) Print the value 5 of integer array bestscores in column format
Q4) Use the double subscripted array to solve the following problem. A company has four sales people
who sell 5 different products, once each day each sales person passes in a slip for different