In Class 10 Exercises - Arrays Assignment Overview Basic use of arrays, using for loop and while loops to fill in and access the array elements. Learning Objectives . Declaring arrays • Understanding the indexing of array elements, how elements are numbered "Subscripting" the array, i.e. indexing • Accessing array elements, i.e. setting elements and using them in calculations Outputing array elements • • Using array elements on the left and right-hand side of expressions, and both . Remembering that the first element in an array is the 0th element Part A Declare an array of 100 int elements, and assign the value (index*index) to each element. For example, arr[3] should be set be equal to 9, arr[5] equal to 25, etc.. Use a for loops. Print the array as in the next box. Use a separate for loop to print the array, one element per line, e.g. arri [0] = 0 arri [1] = 1 arri [2] =4 arri [3] 9 arr1 [99] 9801 Part B 1. Declare an array of 100 int elements, or use the same one. 2. Prompt for a filename and open it to read from it 3. Read 1 number at a time into each element of the array. 4. Use a for loop to read 100 numbers; do not use a while until end-of-file loop because there can be more than 100 numbers in the file! 5. Print the 11, 21", 31", 41, 51" numbers (since indexes start at 0, you are printing arr[10], arr[20], etc.!) a. You do not need a loop or anything special for these 5 lines, you should just use 5 cout statements. 6. Output should look like this, depending on the input file: Input File Name B: input.txt arrB[10] - 11 arrB[20]= -12 arrB[30] - 892 W arrB[40] 28762 arrB[50] -1 Part C Copy the code from Part B. Modify the code to read until end-of-file as well as only read a MAXIMUM of 100 numbers, whichever comes first. Only print the last element in the array, do not print all of the elements in the array. To test this, create a file with only a few numbers in it. Web-CAT will test your program with a small file and with a HUGE file so that your program will NOT work if you do not stop reading after 100 numbers. Output should look like this for a file with just 12 numbers: Input File Name C: inl.in arrc [11] -9786 Or like this if there are 100 or more numbers in the file. You only read the first 100! Input File Name C: in2.in arrC[99] -42 . Test this with exactly 100 mumbers in the file, also, test with 99 mumbers in the file; also, test with 110 numbers, and make sure your code is correct! Test Data 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 98 1 2 3 4 5 96 97
In Class 10 Exercises - Arrays Assignment Overview Basic use of arrays, using for loop and while loops to fill in and access the array elements. Learning Objectives . Declaring arrays • Understanding the indexing of array elements, how elements are numbered "Subscripting" the array, i.e. indexing • Accessing array elements, i.e. setting elements and using them in calculations Outputing array elements • • Using array elements on the left and right-hand side of expressions, and both . Remembering that the first element in an array is the 0th element Part A Declare an array of 100 int elements, and assign the value (index*index) to each element. For example, arr[3] should be set be equal to 9, arr[5] equal to 25, etc.. Use a for loops. Print the array as in the next box. Use a separate for loop to print the array, one element per line, e.g. arri [0] = 0 arri [1] = 1 arri [2] =4 arri [3] 9 arr1 [99] 9801 Part B 1. Declare an array of 100 int elements, or use the same one. 2. Prompt for a filename and open it to read from it 3. Read 1 number at a time into each element of the array. 4. Use a for loop to read 100 numbers; do not use a while until end-of-file loop because there can be more than 100 numbers in the file! 5. Print the 11, 21", 31", 41, 51" numbers (since indexes start at 0, you are printing arr[10], arr[20], etc.!) a. You do not need a loop or anything special for these 5 lines, you should just use 5 cout statements. 6. Output should look like this, depending on the input file: Input File Name B: input.txt arrB[10] - 11 arrB[20]= -12 arrB[30] - 892 W arrB[40] 28762 arrB[50] -1 Part C Copy the code from Part B. Modify the code to read until end-of-file as well as only read a MAXIMUM of 100 numbers, whichever comes first. Only print the last element in the array, do not print all of the elements in the array. To test this, create a file with only a few numbers in it. Web-CAT will test your program with a small file and with a HUGE file so that your program will NOT work if you do not stop reading after 100 numbers. Output should look like this for a file with just 12 numbers: Input File Name C: inl.in arrc [11] -9786 Or like this if there are 100 or more numbers in the file. You only read the first 100! Input File Name C: in2.in arrC[99] -42 . Test this with exactly 100 mumbers in the file, also, test with 99 mumbers in the file; also, test with 110 numbers, and make sure your code is correct! Test Data 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10 98 1 2 3 4 5 96 97
Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
Related questions
Question
Please complete all parts of the assignment in C++ code and make sure all variable names match to the assignment.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 6 steps with 10 images
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Recommended textbooks for you
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education