Complete the PrintArray function to iterate over each element in intVals. Each iteration should put the element to output. Then, put "/" to output. Ex: If intVals's elements are 2 4 7, then output is: 2/4/7/
Added by Tammy B.
Step 1
Step 1: Define the PrintArray function that takes an array of integers (intVals) as a parameter. Show more…
Show all steps
Your feedback will help us improve your experience
Supreeta N and 73 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Supreeta N.
Arrays Write a for loop to print all elements in courseGrades, following each element with a space (including the last). Print forwards, then backwards. End each loop with a newline. Ex: If courseGrades = {7, 9, 11, 10}, print: 7 9 11 10 10 11 9 7 Hint: Use two for loops. The second loop starts with i = NUM_VALS - 1. Note: These activities may test code with different test values. This activity will perform two tests, both with a 4-element array (int courseGrades[4]). Also note: If the submitted code tries to access an invalid array element, such as courseGrades[9] for a 4-element array, the test may generate strange results. Or the test may crash and report "Program end never reached", in which case the system doesn't print the test case that caused the reported message. #include <iostream> using namespace std; int main() { const int NUM_VALS = 4; int courseGrades[NUM_VALS]; int i; for (i = 0; i < NUM_VALS; ++i) { cin >> courseGrades[i]; } /* Your solution goes here */ return 0; }
Shelayah R.
Integer numVals is read from input representing the number of integers to be read next. Use a loop to read the remaining integers from input. For each integer read in the loop, output "quantity >>" followed by the integer. End each output with a newline. Ex. If the input is: 3 70 95 80 Then the output is: quantity >> 70 quantity >> 95 quantity >> 80 #include <iostream> using namespace std; int main() { int numVals; int value; cin >> numVals; for (int i = 0; i < numVals; i++) { cin >> value; cout << "quantity >> " << value << endl; } return 0; }
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD