
DCS1101: Fundamental of Programming Tutorial 8 – Array
1. Define the following arrays:
a) empNum, a 100 -element array of ints
b) pay Rate, a 25-element array of doubles
c) miles, a 14-element array of longs
d) stateCapital, a 50-element array of string objects .
e) lightYears, a 1,000-element array of doubles
2. Assume a program includes the following two statements. They both use square brackets, but they mean different things. int score[15] ; score[6] = 45 ;
a) Which number is the size declarator ?
b) Which number is a subscript?
3. What is the output of the following code? int values[5], count; for (count= 0; count< 5; count++) values[count ] =count+ 1; for (count= O; count< 5; count++) cout << values[count] << endl;
4. Complete the following program skeleton so it will have a 10-element array of int values called fish. When completed, the program should ask how many fish were caught by fishermen 1 through 10, and store this information in the array. Then it should display the data. #include using namespace std; int main () { const int NUMMEN = 10 ; II Define an array named fish that can hold 10 int values. II You must finish this program so it works as II described above. return O; }
5. Define the following arrays :
a) ages, a 10-element array of ints initialized with the values 5, 7, 9, 14, 15, 17, 18, 19, 21, and 23
b) temps , a 7-element array of doubles initialized with the values 14.7, 16.3,18.43, 21.09, 17.9, 18.76, and 26 .7
c) alpha, an 8-element array of chars initialized with the values 'J', 'B', 'L','A' ,"*" ,'$ ', 'H', and 'M'
6. Given the following array definition: int values [ ] = { 2 , 6, 10, 14} ; what do each of the following display?
a) cout << values[2] ;
b) cout << ++values [0] ;
c) cout << values[1]++;
d) x = 2 ; cout << values[++x ] ;
7. Define a two -dimensional array of ints named grades . It should have 30 rows and 10 columns.
8. How many elements are in the following array? double sales[6 ][ 4] ;

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Create a string variable containing your full name (with spaces) 2) print the string as shown below 3) Create a blank 5x10 character array 4) Create a function printArray() that will print every row and column of the array 5) Create a function getNextCharacter() that gets passed the name string and returns the next non-blank character. If you have reached the end of the string then continue at the beginning. You may need to use a global variable 6) Create a function fillArray() that will fill the 2 dimensional array with the letters of your name skipping blanks. Use the above getNextCharacter() function to fill the array with only the characters in your last name. 7) Print the entire array. 8) Request a row number to print and use a sentinal loop to make sure the row number is valid. If not then request a row number again 9) Create a function printIter() that prints only the passed row using iteration 10) Create a function printRecur() that prints only the passed row using recursion…arrow_forwardC programarrow_forward14. Programming Short Questions a) Declare a static array S of type string that holds 50 data.arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





