The capability of comparing addresses gives you another way to be sure a pointer does not go beyond the boundary of an array. demonstrates the use of addresses to avoid going beyond the boundary of an array. Complete the program by filling in the blanks (Make sure that you read the comments after each blank)

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter7: Arrays
Section7.4: Arrays As Arguments
Problem 6E: (Electrical eng.) Write a program that declares three one-dimensional arrays named volts, current,...
icon
Related questions
Question
100%
The capability of comparing addresses gives you another way to be sure a pointer does not go beyond the boundary of an array. demonstrates the use of addresses to avoid going beyond the boundary of an array. Complete the program by filling in the blanks (Make sure that you read the comments after each blank)
// This program uses a pointer to display the
contents
// of an integer array.
#include <iostream>
using namespace std;
int main()
{
int set[8] = {5, 10, 15, 20, 25, 30, 35, 40};
/* define a pointer
named 'nums'
and make it points to
'set' */
// Display the numbers in the array.
cout << "The numbers in set are:\n";
cout <<
// Display first
<< " I
element using pointer
while
) /* Make sure the
address is not greater than the address of
the last element */
{
// Advance nums to point to the next element.
// Display the value pointed to by nums.
cout <<
<< " ".
}
// Display the numbers in reverse order.
cout << "\nThe numbers in set backward are :\n";
cout << *nums << "
element
// Display the last
wh
) /* Make sure the
address is not less than the address of
the first element */
{
// Move backward to the previous element.
// Display the value pointed to by nums.
cout <<
<< " ".
}
return 0;
}
Transcribed Image Text:// This program uses a pointer to display the contents // of an integer array. #include <iostream> using namespace std; int main() { int set[8] = {5, 10, 15, 20, 25, 30, 35, 40}; /* define a pointer named 'nums' and make it points to 'set' */ // Display the numbers in the array. cout << "The numbers in set are:\n"; cout << // Display first << " I element using pointer while ) /* Make sure the address is not greater than the address of the last element */ { // Advance nums to point to the next element. // Display the value pointed to by nums. cout << << " ". } // Display the numbers in reverse order. cout << "\nThe numbers in set backward are :\n"; cout << *nums << " element // Display the last wh ) /* Make sure the address is not less than the address of the first element */ { // Move backward to the previous element. // Display the value pointed to by nums. cout << << " ". } return 0; }
Expert Solution
steps

Step by step

Solved in 3 steps with 3 images

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.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning