Trace the output of the following code

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 1TF: Mark the following statements as true or false. A double type is an example of a simple data type....
icon
Related questions
Question
Trace the output of the following code
#include <iostream>
using namespace std;
int arraySize=5;
void fillArray (int array[ ], int size)
{
for (int i=0; i<size; i++)
{
array[i] = i* 2 + 1;
} }
void printArray (int array[], int size)
{
for (int x-size-1; x>=0; x--)
{
cout << array[x] << " "; }
cout << endl;
}
int main()
{
int num[arraySize] = {0};
printArray (num, arraySize);
fillArray (num, arraySize);
printArray (num, arraySize);
return 0;
}
Transcribed Image Text:Trace the output of the following code #include <iostream> using namespace std; int arraySize=5; void fillArray (int array[ ], int size) { for (int i=0; i<size; i++) { array[i] = i* 2 + 1; } } void printArray (int array[], int size) { for (int x-size-1; x>=0; x--) { cout << array[x] << " "; } cout << endl; } int main() { int num[arraySize] = {0}; printArray (num, arraySize); fillArray (num, arraySize); printArray (num, arraySize); return 0; }
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Program on Numbers
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++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning