C++ Arrays - Bowdoin College

C++ Arrays - Bowdoin College

C++ Arrays Arrays Used to store a collection of elements (variables) type array-name[size]; Meaning: This declares a variable called which contains elements of type The elements of an array can be accessed as: array-name[0],arrayname[size-1] Example: int a[100]; //a is a list of 100 integers, a[0], a[1], a[99] double b[50];

char c[10]; Array example //Read 100 numbers from the user #include void main() { int i, a[100], n; i=0; n=100; while (i> a[i]; i = i+1;

} //do somehing with it .. } Problems Write a C++ program to read a sequence of (non-negative) integers from the user ending with a negative integer and write out

the average of the numbers the smallest number the largest number the range of the numbers (largest - smallest) Example: The user enters: 3, 1, 55, 89, 23, 45, -1 Your program should compute the average of {3, 1, 55, 89, 23, 45} etc

Recently Viewed Presentations

  • www.northernpolarbears.com


    Make your Own Quizzo: 10 pts*Best included in Quizzo & Test Bonus Q's . With a partner, create a 20 Question FrankensteinQuizzo, with an answer key included. Submit your . Quizz
  • Characteristics and Components of an Ecosystem AICE EM:

    Characteristics and Components of an Ecosystem AICE EM:

    What are the major abiotic and biotic factors, which drive and influence the distribution of different ecosystems? The biotic and abiotic factors which control the distribution of the world's major biomes as listed in the notes for guidance.
  • Advancement Via Individual Determination

    Advancement Via Individual Determination

    Tutorology. Family Workshops. College Field Trips. After School Sessions. ... Participate in all AVID after-school sessions on Tuesdays and Thursdays. Maintain a GPA of at least 2.0. Maintain positive behavioral expectations as set by the Student Code of Conduct.
  • EEL4930/5934 Reconfigurable Computing

    EEL4930/5934 Reconfigurable Computing

    Too many possibilities, generally not feasible Routing blue before purple gives shorter wire length Pathfinder 1 1 1 1 1 1 1 1 1 Pathfinder [Ebeling, et al., 1995] Introduced negotiated congestion Ordering independent During each routing iteration, route nets...
  • Présentation PowerPoint - Éducaloi

    Présentation PowerPoint - Éducaloi

    students unscramble the letters to find the name of the government body described in the clues. The slide following the question contains the answer and information about the government body. Note that the names are in French because this is...
  • MEMBERS Horizon - The Value of Risk Control

    MEMBERS Horizon - The Value of Risk Control

    Risk Control Accounts provide a new and innovative method to help manage - even control - investment risk in a portfolio. By leveraging an annuity chassis, we can provide the safety of guaranteed floors on investment performance tied to an...
  • YOUR HEALTH TRIANGLE - Sault Schools

    YOUR HEALTH TRIANGLE - Sault Schools

    evaluating your results. what is the strongest side of your triangle? what is the weakest side of your triangle? write a few sentences about one thing that you can work on to better yourself.
  • Verilog Training

    Verilog Training

    endmodule Simple Verilog Example Verilog Design Description The module_name is an identifier of the modules The port_list is a list of input, output and inout ports which are used to connect to other modules The declares section specifies the type...