I've been at this for a while and I can't seem to crack this.
![5. Download and compile this C code. What happens? $include # include <stdio.h < t dlib . h> int main) int i; int t; srand (time (NULL)) for (i-1 ; i 5000; i++) allilrand / ap the txo array / for (i=0 ; ic#5000; i++) a2[i] = t; /Print the arrays / for (i=0 ; í例000; i++) free (a1); free (a2): Type the program and run it. Save your program as queation5FirstlnitialLastName.c Modify the program so that the program will prompt user for the array size and allocate the correct amount of memory according to the user input. Change the random numbers so that it only generates numbers from 0-600 (not including 600). Submit this program to csc292 as your second program a) b) c)](http://img.homeworklib.com/questions/62799270-7eaa-11eb-b2c1-f1ea226b0694.png?x-oss-process=image/resize,w_560)
a) The program is output is swapping of a1 array i.e., random numbers and a2 iterative numbers(0,1,2,3,...).
suppose a1 have {476774,4653,344454,44363,34563,3443}
a2 have {0,1,2,3,4,5}
after executing:
a1 : {0,1,2,3,4,5}
a2 : {476774,4653,344454,44363,34563,3443}
b)
#include<stdio.h>
#include<stdlib.h>
int main(){
int i;
int t;
int n;
printf("Enter array size: ");
scanf("%d", &n);
int *a1 = (int *)malloc(sizeof(int)*n);
int *a2 = (int *)malloc(sizeof(int)*n);
srand(time(NULL));
for(i=0; i<=n; i++){
a1[i] = rand()%600;
a2[i] = i;
}
for(i=0; i<=n; i++){
t= a1[i];
a1[i] = a2[i];
a2[i] = t;
}
for(i=0; i<=n; i++){
printf("%d : %d\n", a1[i], a2[i]);
}
free(a1);
free(a2);
}
![[rkv-sdc@localhost θ9θ32018]s ./a.out Enter array size: 5 0 383 1 154 2 511 3 : 97 4 : 189 5: 269 [rkv-sdc@localhost 9 32018]](http://img.homeworklib.com/questions/632cc3e0-7eaa-11eb-8aa8-a35b680c3bc7.png?x-oss-process=image/resize,w_560)
I've been at this for a while and I can't seem to crack this. 5. Download...
I need Help PLZ. I can't solving this in C program Given is a C program count_primes.c, which is an array Generates 10000 six-digit random numbers and then determines the number of primes in that array. It also measures the time that elapses during the calculation and returns it to the console along with the number of primes it finds. (a) Rewrite the program so that N threads are used to count the primes in the array. Each thread is...
I need help with coding with c++. I need to make a lottery program where you enter in 5 numbers from 0-9 and the program will generate 5 random numbers 0-9 to represent the lottery numbers. I'm almost done, but the output isn't exactly what I want. It works fine, but the format should look like this: lottery array: 7 4 9 1 3 user array: 4 2 9 7 p.s. I also need to count how many matching numbers...
Create a CodeBlocks project "HW 9" Write the code to ask the user to enter the size of an array. Then create an integer array of that exact size. Ask the user to enter a maximum value and then write a loop to fill the array with random numbers with value in the range of 1 to the maximum value. For example, if the maximum value is 100, random numbers must have value 1 to 100 inclusive. Input size of...
Remove srand(time(NULL)); from this C++ code so that it still finds random numbers correctly. Then, Write a program that adds the following to the fixed code. • Add a function that will use the BubbleSort method to put the numbers in ascending order. – Send the function the array. – Send the function the size of the array. – The sorted array will be sent back through the parameter list, so the data type of the function will be void....
Hello, I am working on a C++ pick 5 lottery game that gives you the option to play over and over. I have everything working right except that every time the game runs it generates the same winning numbers. I know this is an srand or rand problem, (at least I think it is), but I can't figure out what my mistake is. I've tried moving srand out of the loop, but I'm still getting the same random numbers every...
Write a C++ program that simulates a lottery. The user will select 5 numbers 0 through 9 and put this in an array. Then these user numbers are compared to the random numbers the computer generated. The program will display both the computer random number and below the user selected numbers. The program will tell the user how many matches are made. If the user guesses all five you let them know they are the grand winner. Here is the...
I have a programming assignment for a introductory c++ class and I am really struggling writing this program. Below are the assignment requirements, I am unable to use vectors in stl and I keep getting a ton of compiling errors. Thank you chegg experts. You have really helped me out this semester. Your responses and code has cleared up so many issues ive had. Description The purpose of this challenge is to employ the use of basic functions and arrays....
I ONLY NEED PART 4 I HAVE DONE 1,2,3 Arrays This assignment is designed in small progressive parts, with the intention of developing the skill of working with arrays. Do each part separately. Include in your submission the code and output for Part I, then the code and output for Part 2, etc. into a Word document. Specification: Part 1. Write a main function that declares an array of 10 int’s. Assign each element in the array a value between...
Q2. Consider the following C++ program that declares, allocates and fills in a1D array with random numbers between 0 and 100. The array is sent to a function that finds the indices of all items > 50. A new array is created and the indices are stored inside it. The size of the new arrays MUST BE the same as the number of items > 50. The function returns the new array which is then printed out by main. Here...
I am reading a text file and trying to store the information into an array so I can use this in different parts of my program. So a dynamic array. So far I have been able to retrieve the information from the text file and organize it by category (User name,User ID, User password) I am having troubles allocating an array and storing the information correctly. Since I have different data types (int, string) do I need to create a...