Look at the following array definition: int values[10]; How many elements does the array have? What is the subscript of the first element in the array? What is the subscript of the last element in the array? Assuming that an int uses 4 bytes of memory, how much memory does the array use?

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
icon
Related questions
Question
Look at the following array definition: int values[10]; How many elements does the array have? What is the subscript of the first element in the array? What is the subscript of the last element in the array? Assuming that an int uses 4 bytes of memory, how much memory does the array use?
Expert Solution
Explanation

1) An array is a collection of similar data elements stored at contiguous memory locations. It is the simplest data structure where each data element can be accessed directly by only using its index number.

2) The array has a fixed size meaning once the size is given to it, it cannot be changed i.e. you can’t shrink it nor can you expand it

3) Indexing in array

  • First element of array is indexed by a subscript  of 0
  • Second element of array is indexed by a subscript  of 1
  • Nth element in array is indexed by a subscript  of 1

4) Size of array depends upon the size of array and type of variables

5) We have an array in question

  • int values[10];
  • This array has 10 elements indexed from 0 to 9
  • Subscript of the first element in the array is values[0]
  • Subscript of the last element in the array is values[9]
  • int has size of 4 bytes, so size of array is
    • 4*10 = 40 bytes
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Array
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
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)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education