219k views
4 votes
Assume that an array named a containing exactly 5 integers has been declared and initialized. Write a single statement that adds 10 to the value stored in the first element of the array.

User Ochi
by
5.1k points

1 Answer

4 votes

Answer:

"a[0]=a[0]+10;", is the correct answer for the above question.

Step-by-step explanation:

  • An array is defined as a user-defined data type used to store multiple variables of the same type in a continuous passion in a memory.
  • To declare an array a user needs to define the size and it referred many variables by one name but the index of that variable is different,
  • The array takes an index from 0 to (size-1). It means that the first index of the array is 0. So if the name of that array is A then the first variable name is A[0].
  • The above-question says that there is an array of name 'a' then its first variable name is a[0] then we can add 10 to its like "a[0]=a[0]+10". Here '=' is an assignment operator and '+' is an addition operator.
User David Thornley
by
5.4k points