PRETTY DIFF This diff is colored to make it clear what parts of the output are wrong. Green indicates things in the correct output that you are missing, red indicates things in your output that shouldn't be there. The - character refers to newlines, so the green e character refers a newline you are missing in your output and the red refers to a newline you need to remove from your output. 1 randArray[e ]- 65d 2 randArray[1 ]- 57d 3 randArray[2 ]- 39d 4 randArray[3 ]- 47d randArray[4 ]- 79d 6 randArray[5 ]- 59d 7 randArray[6 ]- 45d 8 randArray[7 ]- 11d 9 randArray[8 ]- 53d 10 randArray[9 ]- 27d 11 randArray[10 - 14 randArray[11 - 654 13 randArray[12 ]- 79d 14 randArray[13 15 randArray[14 - 82d randArray[15 - 784 12 764 16

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter6: Looping
Section: Chapter Questions
Problem 2CP
icon
Related questions
Question

Getting an error with my code. Below I have included a screenshot 

Instruction:

DESCRIPTION
  • In main() for now: do these - one at a time, each in it's own loop (we will make functions out of them later

–Declare an array RandArray with 20 integers

–Assign each of the 20 values with a random value from 0 to 99

  • Hint: Use rand()%100
  • For mimir: Do not call srand at the top of main.

// normally: Call srand(time(0)) at the top of main

–(you need #include<cstdlib>)

–Write another loop that prints the array, with index values

Important:

If the output values do not match mimir, please add

srand(17); // inside your main function - at the top

My code:

#include <iostream>

using namespace std;

 

#include <cstdlib>

 

int main()

{

srand(17);

const int ARRAYSIZE = 20; // size for the array

int RandArray[ARRAYSIZE]; // array declared

 

int i; // to iterate the loop

 

// this loop will store the

// random numbers in the array

for (i = 0; i < ARRAYSIZE; i++)

RandArray[i] = rand() % 100;

 

// this loop will print the array

for (i = 0; i < ARRAYSIZE; i++)

cout << i << " = " << RandArray[i] << endl;

 

return 0;

}

PRETTY DIFF
This diff is colored to make it clear what parts of the output are wrong. Green indicates things in the correct output that you are missing, red
indicates things in your output that shouldn't be there.
The - character refers to newlines, so the green e character refers a newline you are missing in your output and the red refers to a newline you
need to remove from your output.
1 randArray[e ]- 65d
2 randArray[1 ]- 57d
3 randArray[2 ]- 39d
4 randArray[3 ]- 47d
randArray[4 ]- 79d
6 randArray[5 ]- 59d
7 randArray[6 ]- 45d
8 randArray[7 ]- 11d
9 randArray[8 ]- 53d
10 randArray[9 ]- 27d
11 randArray[10 - 14
randArray[11 - 654
13 randArray[12 ]- 79d
14 randArray[13
15 randArray[14 - 82d
randArray[15 - 784
12
764
16
Transcribed Image Text:PRETTY DIFF This diff is colored to make it clear what parts of the output are wrong. Green indicates things in the correct output that you are missing, red indicates things in your output that shouldn't be there. The - character refers to newlines, so the green e character refers a newline you are missing in your output and the red refers to a newline you need to remove from your output. 1 randArray[e ]- 65d 2 randArray[1 ]- 57d 3 randArray[2 ]- 39d 4 randArray[3 ]- 47d randArray[4 ]- 79d 6 randArray[5 ]- 59d 7 randArray[6 ]- 45d 8 randArray[7 ]- 11d 9 randArray[8 ]- 53d 10 randArray[9 ]- 27d 11 randArray[10 - 14 randArray[11 - 654 13 randArray[12 ]- 79d 14 randArray[13 15 randArray[14 - 82d randArray[15 - 784 12 764 16
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Assembly Language
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
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
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:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT