bMy Questions | bartlebyCourse Schedule - Fall 2 Xhttps://myleoonline.tamuc.edu/d2l/le/calendar/36472/event/125969/detailsview#125969TNUV 1Z, ZUI7 T.V TTTAdd a task...Fall 2019 - Programming Fundamentals II (COSC-1437-01E-02 B)In your program, you will randomly generate integer numbers between -50 and+50 (including -50 and +50). You will repeat this process 1000 times. Whilegenerating these numbers, you need to count the numbers based on their signsseparately, as positive and negative. For instance, if your program generate +2515 times, and -25 19 times. Then this should be reported as,Num PosFre NegFre251519For this problem, you need to use array of struct, similar to depicted below.NumberPosFreNegFreNumberPosFreNegFreNumberPosFreNegFreNegFreNumberPosFreReport all number from 1 to 50 in an ascending order. Note that you will not useany sort algorithm in this assignment.2:35 PMOType here to searchENG11/12/2019Xt bMy Questions | bartleby+Course Schedule - Fall 2 Xhttps://myleoonline.tamuc.edu/d2l/le/calendar/36472/event/125969/detailsview#125969NumberNegFrePosFreNumberPosFreNegFreNumberPosFreNegFreNumberPosFreNegFreReport all number from 1 to 50 in an ascending order. Note that you will not useany sort algorithm in this assignment.A sample output is given asNum PosFre NegFre1134554259163554354944295035692:36 PMOType here to searchENG11/12/2019XtLO

Question
Asked Nov 12, 2019
2 views

write a c++ program from the attachments below

bMy Questions | bartleby
Course Schedule - Fall 2 X
https://myleoonline.tamuc.edu/d2l/le/calendar/36472/event/125969/detailsview#125969
TNUV 1Z, ZUI7 T.V TTT
Add a task...
Fall 2019 - Programming Fundamentals II (COSC-1437-01E-02 B)
In your program, you will randomly generate integer numbers between -50 and
+50 (including -50 and +50). You will repeat this process 1000 times. While
generating these numbers, you need to count the numbers based on their signs
separately, as positive and negative. For instance, if your program generate +25
15 times, and -25 19 times. Then this should be reported as,
Num PosFre NegFre
25
15
19
For this problem, you need to use array of struct, similar to depicted below.
Number
PosFre
NegFre
Number
PosFre
NegFre
Number
PosFre
NegFre
NegFre
Number
PosFre
Report all number from 1 to 50 in an ascending order. Note that you will not use
any sort algorithm in this assignment.
2:35 PM
OType here to search
ENG
11/12/2019
X
t
help_outline

Image Transcriptionclose

bMy Questions | bartleby Course Schedule - Fall 2 X https://myleoonline.tamuc.edu/d2l/le/calendar/36472/event/125969/detailsview#125969 TNUV 1Z, ZUI7 T.V TTT Add a task... Fall 2019 - Programming Fundamentals II (COSC-1437-01E-02 B) In your program, you will randomly generate integer numbers between -50 and +50 (including -50 and +50). You will repeat this process 1000 times. While generating these numbers, you need to count the numbers based on their signs separately, as positive and negative. For instance, if your program generate +25 15 times, and -25 19 times. Then this should be reported as, Num PosFre NegFre 25 15 19 For this problem, you need to use array of struct, similar to depicted below. Number PosFre NegFre Number PosFre NegFre Number PosFre NegFre NegFre Number PosFre Report all number from 1 to 50 in an ascending order. Note that you will not use any sort algorithm in this assignment. 2:35 PM OType here to search ENG 11/12/2019 X t

fullscreen
bMy Questions | bartleby
+
Course Schedule - Fall 2 X
https://myleoonline.tamuc.edu/d2l/le/calendar/36472/event/125969/detailsview#125969
Number
NegFre
PosFre
Number
PosFre
NegFre
Number
PosFre
NegFre
Number
PosFre
NegFre
Report all number from 1 to 50 in an ascending order. Note that you will not use
any sort algorithm in this assignment.
A sample output is given as
Num PosFre NegFre
1
13
45
54
2
59
16
3
55
4
35
49
44
29
50
35
69
2:36 PM
OType here to search
ENG
11/12/2019
X
t
LO
help_outline

Image Transcriptionclose

bMy Questions | bartleby + Course Schedule - Fall 2 X https://myleoonline.tamuc.edu/d2l/le/calendar/36472/event/125969/detailsview#125969 Number NegFre PosFre Number PosFre NegFre Number PosFre NegFre Number PosFre NegFre Report all number from 1 to 50 in an ascending order. Note that you will not use any sort algorithm in this assignment. A sample output is given as Num PosFre NegFre 1 13 45 54 2 59 16 3 55 4 35 49 44 29 50 35 69 2:36 PM OType here to search ENG 11/12/2019 X t LO

fullscreen
check_circle

Expert Answer

Step 1

Answer:

Program:

#include <iostream>
#include <cstdlib>
#include <iomanip>

using namespace std;

struct number
{
int n;
int pos;
int neg;
};

int main()
{
struct number arr[100];
 
int r;
 
for(int i = 0; i<=50; i++)
{
arr[i].n = i;
arr[i].neg = 0;
arr[i].pos = 0;
}
 
for(int i = 0; i<1000; i++)
{

r = rand() % 101 - 50;

if(r < 0)
{
arr[abs(r)].neg = arr[abs(r)].neg + 1;
}
else
{
arr[r].pos = arr[r].pos + 1;
}
}
 
cout<<"Num"<<setw(10)<<"PosFre"<<setw(10)<<"NegFre"<<endl;
 

for(int j = 1; j<=50; j++)
{
cout<<arr[j].n<<setw(7)<<arr[j].pos<<setw(10)<<arr[j].neg<<endl;
}
 
return 0;
}
 
Output:
 
Num PosFre NegFre
1 8 11
2 4 8
3 10 10
4 8 12
5 9 4
6 5 12
7 14 12
8 10 5
9 14 10
10 9 10
11 12 17
12 11 10
13 11 13
14 12 8
15 11 12
16 10 8
17 9 12
18 8 11
19 10 10
20 10 8
21 14 8
22 9 11
23 9 11
24 3 9
25 11 13
26 13 11
27 19 8
28 11 6
29 6 8
30 9 8
31 13 11
32 7 10
33 13 6
34 10 8
35 6 11
36 9 12
37 12 11
38 6 7
39 11 9
40 4 17
41 8 11
42 8 16
43 8 14
44 13 6
45 9 14
46 9 11
47 15 9
48 5 10
49 8 7
50 12 15
 
 
Step 2
Step 3

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: Write the pseudocode  and Flowchart for a program that simulates the Magic eight ball game.

A: Pseudocode:Pseudocode is a detailed description of the algorithm of a program that is easier to read...

question_answer

Q: Using Java Eclipse create the following program

A: Below is the approach and java code to create an ArrayList which adds three objects Loan, Date, Circ...

question_answer

Q: Using C++ complete the following program Monkey BusinessA local zoo wants to keep track of how many ...

A: Program Instructions:Declare a two dimensional 3*7 array and a one dimensional array to store weeks....

question_answer

Q: 2. (5.12 in 8e) answer each of the followig question. a) what does it mean to choose numbers "at ran...

A:  a) Choosing numbers at random means that any number can be selected and every number has an equal c...

question_answer

Q: Most modern TCP implementations use pseudo-random number generators (PRNG) to determine starting seq...

A: The ith number can be generated if (i-1)th number is generated, and thus the entire series can be ge...

question_answer

Q: A two-dimensional random walk simulates the behavior of a particle moving in a grid of points. At ea...

A: A java program that takes an integer command-line argument “n” and simulates the motion of a random ...

question_answer

Q: 4.7: Time Machine Your time machine is capable of going forward in time up to 24 hours. The machine ...

A: Following is the c++ program:Variables used:startHours, startMins are used to store the starting tim...

question_answer

Q: I need help with a C program     /* Figure 6.2 */ /* Reads each number from an input file and wri...

A: Program://inlcude the required header files#include &lt;stdio.h&gt;#include &lt;stdlib.h&gt; //defin...

question_answer

Q: In C++ Language: Write a function SummOdd that will find the sum of all elements of add order a1+ a3...

A: As it is not clear in the question that sum of odd order for the arr[]={ 8,6,4,2,3,5} is 8 (3+5=8 i....