Nt1420 Unit 8

Decent Essays
Complete the following problems.

1. Write C++ statements to do the following:

a. Declare an array alpha of 15 components of type int. int[] alpha = new int[15];
b. Output the value of the 10th component of the alpha array.
System.out.println(alpha[10]);

c. Set the value of the 5th component of the alpha array to 35. alpha[4]=35 d. Set the value of the 9th component of the alpha array to the sum of the 6th and 13th components of the alpha array. Alpha[8]=(6*13)
e. Set the value of the 4th component of the alpha array to three times the value of the 8th component minus 57. alpha[3]=(3*alpha[7])-57; f. Output alpha so that five components appear on each line. int counter = 0; for (int i = 0; i < 3; i++) { counter = (i * 5); System.out.println(alpha[counter] + " " + alpha[counter + 1] + alpha[counter + 2] + " " + alpha[counter + 3] + " " + alpha[counter + 4]); }
…show more content…
What is stored in the list array after the following code executes?

int list[5]; for(int j = 0; j < 5; j++) { list[j] = 2 * j + 5; if (j % 2 == 0) { list[j] = list[j] - 3; } }
The numerical values of 2,7,6,11,10
3. What does array index out of bounds mean? What can happen if this occurs in your program? This means that the value given is either a negative or is greater than or equal to the size of the array. If this occurs within your program than you will get a runtime error causing the program to not fully operate.

4. Write C++ statements to define and initialize the following arrays using appropriate data types:

a. An array of heights has 6 components which have the following values: 5.5, 5.8, 6.3, 6.6, 4.9, 5.9. b. An array of weights has 4 components which have the values: 140, 165, 190, 207. c. An array of symbols which contains the following characters: '$', '%', '@', '!', '|',

Related Documents

  • Decent Essays

    Ecet 340 Week 4

    • 1985 Words
    • 8 Pages

    ECET 340 Week 4 HomeWork 4 Purchase here http://devrycourse.com/ecet-340-week-4-homework-4 Product Description Determine the conversion time for an ADC0804 (8-bit), where 66 clocks per bit are required, if its clock frequency is 50 kHz. 2. If an 8-bit SAR has Vref = 10 V, what is the binary value for an input voltage of 7.28 V? 3. What is the percent error for the binary answer found in Problem #2?…

    • 1985 Words
    • 8 Pages
    Decent Essays
  • Decent Essays

    Those values were 3.6 for area, 25.3 for volume, and 10.8 for density. After that the percent uncertainty was calculated by using the formula 100(uncertainty)/(original value). The values for area, volume, and density are 1.53, 4.23, and 4.09. The expected percentage was then calculated by adding up the percentages from the dimensions used in calculating the quantity. For area the expected was 1.52, the volume 4.23, and for density 4.29.…

    • 976 Words
    • 4 Pages
    Decent Essays
  • Decent Essays

    The third implementation uses PPSO where results are shown below in table 4: Table 4: Results of PPSO x P Sp CF ET 1 2 1.33 58.73 0.02 2 4 1.60 24.48 0.017 3 8 1.79 15.00 0.012 4 16 1.89 5.85 0.008 5 32 1.96 5.85 0.005 6 64 2.00 5.85 0.003 7 128 2.00 5.34 0.002 8 256 2.00 2.73 0.001 9 512 2.00 2.73 0.001 10 1024 2.00 2.73 0.0003 In table 4 each test case (iteration) to optimize the cost function but elapsed time decreased compared with MCWA, PSO and shown below in figure 5: Figure 5:Releationship between CF and ET in PPSO In figure 5 shown relationships between CF and ET where found inverse relationship between them. This paper introduces compared between PSO and PPSO where shown below in figure 6: Figure 6:Releationship between PSO and PPSO In figure 6 shown relationships between PSO and PPSO where elapsed time in PPSO decreased compared with PSO. In figure 7 shown relationships between SP, PSO and PPSO. Figure 7:Releationship between SP, PSO and PPSO In figure 7 shown inverse relationships between SP, PSO and PPSO Whenever an increase in speed occur where decreased in PSO and also more decreased in…

    • 1263 Words
    • 6 Pages
    Decent Essays
  • Decent Essays

    End-Of-Chapter Quiz

    • 680 Words
    • 3 Pages

    (1 point) Correct answer DSUM 13) The use of two or more conditions on the same row—all of which must be met for the records to be included in the results. (1 point) Correct answer Compound criteria 14) A database function that determines the number of occurrences of a specified condition in a database. (1 point) Correct answer DCOUNT 15) Formatting characteristics that are applied to cells when the value in the cell meets a specified condition are called: (1 point) Correct answer Conditional formats 16) In Excel, you can insert an image of an open window called a: (1…

    • 680 Words
    • 3 Pages
    Decent Essays
  • Decent Essays

    4. PROPOSED WORK This work 16-bit speculative Han-Carlson adder (HCA) is proposed. Speculative prefix adders can be subdivided in five stages: pre-processing, speculative prefix-processing, post-processing, error detection and error correction. The error correction stage is off the critical path, as it has two clock cycles to obtain the exact sum when speculation fails. 4.1 Pre-processing stage The propagate and generate signals are computed as in equations (1) & (2).…

    • 1491 Words
    • 6 Pages
    Decent Essays
  • Decent Essays

    Well 1 was blank, well 2 was 100bp ladder, well 3-6 were restriction enzyme digested PCR products, in which, well 3 was Kpn I, well 4 was BstE II, well 5 was Nar I and well 6 was BssH II. Size of base pair was showed in well 1 for measurement. Number of fragment in this result was 3 3 3 3. The fragment size in well 3 and 4 were about 70-80bp, 160-170bp and230-240bp. Well 5 and 6 were about 150-160bp, 260-270bp and 410-420bp.…

    • 2138 Words
    • 9 Pages
    Decent Essays
  • Decent Essays

    Web. 12 Oct. 2016. Joyce, Catherine M., and Thomas A. Steitz. "Function and Structure Relationships in DNA Polymerases." Annual Review of Biochemistry 63.1 (1994): 777-822.…

    • 1517 Words
    • 7 Pages
    Decent Essays
  • Decent Essays

    These parameters are input as string which is presented as {2,3,3}. From this input, CBPTT split based on commas. This resulted in p which started from 0 to increment based on the split value. Then, p became the quantity of parameter which is 3. Parameter value was retrieved when information was converted in integer.…

    • 1357 Words
    • 6 Pages
    Decent Essays
  • Decent Essays

    Nt1310 Unit 8 Lab Report

    • 494 Words
    • 2 Pages

    To measure the loop overhead, we have enclosed a for (j = 0; j < 1; j++) loop inside a averaging loop of 500,00 times and summarized the results. Predictions: Reading time includes (1) allocating register, (2) copy the clock cycles to register, (3) store in a variable (4) to and from jumps and this repeats for measuring start and end time, so twice the number of instructions. Assuming 1 clock cycle / instruction, our base hardware estimate was 5 clock cycles. So to measure start and end time, it will be 10 clock cycles. Software estimate includes validation of asm routine, assembling instructions, protection checks and register checks.…

    • 494 Words
    • 2 Pages
    Decent Essays
  • Decent Essays

    Distance And Age Of M52

    • 1078 Words
    • 4 Pages

    The turnoff point located 11.4 indicating the rough age of the M52 cluster. Deriving the distance and age of M39 In comparison with Figure 1 the main sequence, turnoff point, and giant red for M39 are identified and clearly shown in figure 3. As before the colour excess for M39 is 0.01 resulting Av = 3× 0.01 = 0.03. The apparent magnitude mv is 8.8 and the absolute magnitude Mv is +0.70. The uncertainty in the main sequence recorded the maximum value 15.00 and minimum value 9.00 in Y-axis which gives 15.00-9.00 = ± 6.00.…

    • 1078 Words
    • 4 Pages
    Decent Essays