QUESTION 5 Given the code: srand(time(NULL)); int CAPACITY = 10; int a[CAPACITY]; Output Example 5 625292689 5.4 1. Write a loop to store random values from 0 to CAPACITY-1 inclusive into the array. 2. Write a loop to print the array and calculate the average of all values. 3. Write a line of code to print the calculated average to the console.
Q: Write the function average which returns the mean of the given array (that is, the sum divided by…
A: Given: #include<iostream> #include<cstddef> double *l,*m; using namespace std; double…
Q: Simulate binary search Use array {1, 2, 3, 4, 5, 6, 7} to simulate binary search of 3. For each…
A: Solution: Binary Search: Binary search is used to search a key element from multiple elements.…
Q: A common memory matching game played by young children is to start with a deck of cards that contain…
A: Program: //using header file #include <iostream> #include <time.h> #include…
Q: 1. Write an assembly language program that clears the screen, locates the cursor near the middle of…
A: (1.) INCLUDE Irvine32.inc .data prompt BYTE "Enter a 32-bit signed integer:",0 resultMsg…
Q: c++ Redo Programming Exercise 6 of Chapter 8 using dynamic arrays. The instructions have been…
A: Note : a)Verify the file name of input file. In the program it is given like…
Q: Extend the below program such that when reading the 3 values per record from the file, the values…
A: Programing instructions: Declare the required variables. Open the file in the reading mode. Read…
Q: Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the…
A: Inside the Task scheduling class, you specified the exception classes InvalidTimeException and…
Q: Consider 2 integer arrays, x and y, each with size equal to 10. Initialize array x with random…
A: Since you have not mentioned the programming language in the question so, we have used C++…
Q: Step Use the scanner object to read an int from the user representing how many words you will read.…
A: Given:
Q: Given the array: array a ={1,2,3,4 }; Using a "for" loop(s) write a segment of code to print the…
A: Given: To write a Code in C++.
Q: Movie x = new Movie("ET...","Et was from Jupiter", 6.0, 2); CD cd = new CD("Best","Xcompany",15.0,…
A: JAVA public class Item { private String title; private String description; private…
Q: Language: C Write a program where you first read an integer n, then n integers are read from the…
A: 0.Start 1.Ask user input for number of digits 2.Allocate memory space for array 3.Ask user for value…
Q: b) Write a program that prints the following multi-dimensional array using for loop. int arr[5][3] =…
A: Hi. As you have not mentioned any programming language and by looking at the syntax I am assuming…
Q: (a) Define DUP operator in an array. Show the output of the command LINE DB 1, 2, 3 DUP (3 DUP (0),…
A: a) Define DUP operator in an array . show the output of the command LINE DB 1,2,3 DUP(3 DUP(0) ,1,8)…
Q: Write java code to check if int array contains any repeated number If array contains any repeated…
A: HI THERE I AM ADDING JAVA CODE AS PER BELOW REQUIREMENT PLEASE GO THROUGH IT THANK YOU Take array…
Q: Write a java program that declares an array to hold 12 integers. The contents of the array should…
A: Given: Write a java program that declares an array to hold 12 integers. The contents of the array…
Q: complete and create magical square #include using namespace std; class Vec { public: Vec() { }…
A: #include <iostream> using namespace std; class Vec { public: Vec() { } int size() { return…
Q: Problem D. 73511. Quarters Input file: Output file: standard input standard output 1 second 256…
A: #include <stdio.h> int main() { int m,n; //read m and n scanf("%d…
Q: 2. you have data of size 499 byte stored in an array starting at 45000H, write a program to check…
A: Microprocessor is a controlling unit of a micro-computer, fabricated on a small chip capable of…
Q: Given the following array and what it looks like when printed to the console: char a[3][4] = {…
A: Given the following array and what it looks like when printed to the console:char a[3][4] = {…
Q: //Write the assembly for the following loop # // Use indexed array access (no pointers) # const int…
A: here, I have to write assembly code for the question.
Q: 2) Read an integer input from the user and save it to a variable 'size'. - Use the variable 'size'…
A: As the programming language is not mentioned the following code is in c++ CODE : #include…
Q: Write a program that takes 6 integers from user and store them in an array. Calculate the Sum,…
A: Below is the required C program: - Program Approach: - Defining the necessary header file.…
Q: Arrays a1, a2… are populated as shown; display a[i] for each calls to arr; if a[i] less than or…
A: class Test98 { public static void main(String args[]) { int a[] = {1, 1, -1, 1, 0, -1, -2, 2, -4,…
Q: C++ program that reads first name and last name from two txt files,
A: Program: #include <stdio.h>#include <stdlib.h>#include <iostream>using namespace…
Q: Q1 Write a program to ask the user to record students' ratings between (0 – 10) for 20 students into…
A: Java Code :- (Language is not specified in the question) import java.util.*;class Main {…
Q: Ask the user to enter a size of array between 2 to 10. Based on the size entered, write a loop which…
A: import java.util.*; class SplitClass { public static boolean splitEqual(int[] arr, int size){…
Q: 1. Illustrate how the how the following code allocates memory: #define N 100 //global variable int…
A: #define N 100 : replace the N with the number defined and compiles the code, this is done during the…
Q: Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the…
A: Since, you haven't mentioned the programming language, we are answering this question in java.
Q: Q1. Write a program to do the following : (1) Declare an array a of size 10 and three pointer…
A: Hello Student. Greetings from my side. Hope you are doing great. I will try my best to answer your…
Q: • Write a program that asks the user for 3 integer values and stores them in an array. Then, in a…
A: First input the three numbers. Store these numbers into the array. Now we will create a pointer…
Q: What value does f2 return when it is passed an array of integers A = {1,2, 3, 4, 5, 6, 7, 8, 9, 10},…
A: Correct answer is : Option b - 21
Q: QUESTION 5 Given the code: srand(time(NULL)); int CAPACITY = 10; int a[CAPACITY]; Output Example 5 6…
A: Note: since programming language is not specified, we are providing answer in c…
Q: def t19(N, s, X, y): Inputs: - N: An integer s: A floating-point number - x: A floating-point number…
A: import numpy as np def t19(N, s, x, y): Arr = np.empty((N,N)) for i in range(N); for…
Q: Can someone please explain this C++ code that my classmate did line by line please. Also, incase…
A: Here we have an array of integers with size 5 in which the user enters the number. Then, we have…
Q: You have an array of size 560 byte stored in memory locations starting at 43000 H. Write a program…
A: I have answered in this question step 2.
Q: You are supposed to manage records of multiple squares. Write a C++ program that store length of 15…
A: Introduction of the Program: The C++ program takes 15 square lengths from the user and stores all…
Q: The output of the following code int a[3] = { 1, 2, 3 }; printf( "a[0] = [%d] = %d", a,*a); %3D %3D…
A: Given: #include<stdio.h>int main(){ int a[3]={1,2,3}; printf("a[0]=[%d]=%d",a,*a);} Find the…
Q: Question: If two arrays have the same size, we can "add" them as we do with vectors. For example: х1…
A: Required: in C++ please
Q: int a[10] = {1,2,3}; 1. Write a loop to print the array to the console. 2. Write the output of…
A: Since the programming language is not mentioned , I have done the code in C++ language. Algorithm :…
Q: Given
A: for(int i=0;i<3;i++) { for(int j=0;j<4;j++) { if(j==2) cout<<a[i][j]<<" ";…
Q: I have a MIPS program I'm working on and I need to make it so that the following print loop I have…
A: Here we write assembly code to reverse the string(my…
Q: You have been asked to code a solution for the following problem: 1. Read a file that contains the…
A: The question asks to read data from a text file - weights.txt and perform - display, sorting and…
Q: #include using namespace std; //swapping void swapping(int &a, int &b) { //variable…
A: The modified code without using function is written below:…
Q: Write a program that creates a 10 element double array to store program grades and reads 10 values…
A: using System; namespace Grades{ public class Program { static void Main(string[] args) {…
Q: What will be the final value of EAX in this example? mov eax, 0 mov ecx, 10 L1: mov eax, 3 mov…
A: Solution: Note: Since all four are different questions i would prefer to solve the first question if…
Note: It`s C++
Step by step
Solved in 3 steps with 2 images
- Write a program that allows students to schedule appointments at either 1,2,3,4,5 as days of the week; 1 for Monday, 2 for Tuesday and so on. Use an array of five strings to store the names for the time slots. Write a loop that iterates as long as the array has a free space. Within a try block, allow the user to enter a day and a name. If the day is free, put the name in the array. If the day is not free, throw an Exception. If the day is not valid, throw another exception. Use catch block for each different kind of exception.What will be the final value of EAX in this example? mov eax, 0 mov ecx, 10 L1: mov eax, 3 mov ecx, 5 L2: add eax, 5 loop L2 loop L1 (ii) Write a program that calculates the following expression, using registers: A = (A + B) − (C + D) (iii) Write a program that uses a loop to copy all the elements from an unsigned Word array into an unsigned doubleword array. (iv) Write a program that displays a string in all possible combinations of foreground and background colors (16 x 16 =256). The colors are numbered from 0 to 15, so you can use a nested loop to generate all possible combinations. Also use a delay of 1s in each foreground color change.Consider 2 integer arrays, x and y, each with size equal to 10.Initialize array x with random numbers between 1 and 100.Write code that fills array y with values such that each element of y is the corresponding valueof x multiplied by its index.
- Write a loop that iterates through a doubleword array and calculates the sum of its elementsusing a scale factor with indexed addressingcan you write it in java.util.scanner form and can you make so i can copy and past it please, thank you. ☜ (゚ヮ゚☜) Simulate binary search Use array {1, 2, 3, 4, 5, 6, 7} to simulate binary search of 3. For each iteration, you need to write down the value of first, last, and middle after the execution of this statement: middle = (first + last) / 2 follow the loop until you get the search result. After you are done, update the BinarySearchDemo.java class to use this array for search. Compare the print out result to your simulation result.For some reason I have 2 programs that aren't running. This is the second one, please let me know if everything is correct. (And I have tried changing class to main but that doesn't work) My code: class Program12two {//PSEUDOCODE //Write a program that creates a small (6-10) array of ints //Display your array elements, all on one line, using a foreach loop //In a try block, prompt the user to enter an index for the array and attempt to print the element with that index //Follow the try block with two catch blocks: //one that detects an index out of bounds //another that catches other bad inputs public static void main(String[] args) { Scanner in = new Scanner(System.in); int[] arr = {12, 15, 24, 5, 9, 16}; for (int num: arr) { System.out.print(num + " "); } System.out.println(); try { System.out.print("Enter any index of your array "); int index =…
- Write a program that grades arithmetic quizzes as follows: (Use the below startup code for Quizzes.java and provide code as indicated) Ask the user how many questions are in the quiz. Use a for loop to load the array. Ask the user to enter the key (that is, the correct answers). There should be one answer for each question in the quiz, and each answer should be an integer. They can be entered on a single line, e.g., 34, 7, 13, 100, 8 might be the key for a 5-question quiz. You will need to store the key in an array called “key”. Ask the user to enter the student’s answers for the quiz to be graded. There needs to be one answer for each question. Note that each answer can simply be compared to the key as it is entered. If the answer is correct, add 1 to a correct answer counter. Do this in a separate for loop from the loop used to load the array. When the user has entered all of the answers to be graded, print the number correct and the percent correct. When this works, nest your for…Write a block of code that uses a dynamic allocated array named Array to (1) Load ten integers from the user into the memory, (2) Find the number of negative integers in the array, and (3) Print a message with the number of negatives. Whenever no numbers are negative print an additional message "No negatives!" (Assume all libraries are included)Write a menu driven program that reads an array of 10 integer from standard keyboard (user) utilizing a loop and outputs the following depending on user's choice • Choice 1 - Prints the elements of array . Choice 2 - Prints the minimum value of the array Choice 3 - Prints the maximum value of the array Choice 4 - Prints the product of all the numbers utilizing aloop. Choice 5 - Prints the sum of all the numbers utilizing a loop Choice 6- Print the elements of array in a reverse order When the program is done, your program should ask the user if they would like to enter another set of 10 numbers and the program should repeat itself. Input validation: Your program should only accepts integers.
- Write a hangman game that randomly generates a word andprompts the user to guess one letter at a time, as presented in the sample run.Each letter in the word is displayed as an asterisk. When the user makes a correctguess, the actual letter is then displayed. When the user finishes a word, displaythe number of misses and ask the user whether to continue to play with anotherword. Declare an array to store words, as follows:// Add any words you wish in this arrayString[] words = {"write", "that",...}; (Guess) Enter a letter in word ******* > p↵Enter(Guess) Enter a letter in word p****** > r↵Enter(Guess) Enter a letter in word pr**r** > p↵Enterp is already in the word(Guess) Enter a letter in word pr**r** > o↵Enter(Guess) Enter a letter in word pro*r** > g↵Enter(Guess) Enter a letter in word progr** > n↵Entern is not in the word(Guess) Enter a letter in word progr** > m↵Enter(Guess) Enter a letter in word progr*m > a↵EnterThe word is program. You missed 1 timeDo…public int binarySearch(int[]array, int num) {int low = 0;//low rangeint high = array.length -1; //high range int mid; //mid rangewhile () //while low is less than or equal to high{mid = ; //set middle range to be (low + high) /2if () { //if the array in the middle range = input number//return mid range }elseif () { //if the array in the middle range > input number//set the high value to be the mid value minus 1 }else{//set low value to be mid value plus one } }//return -1 here because that would mean that the number is not found in the loop}A run is a sequence of adjacent repeated values. Write a program that generates a sequence of 20 random die tosses in an array and that prints the die values, marking the runs by including them in parentheses, like this:1 2 (5 5) 3 1 2 4 3 (2 2 2 2) 3 6 (5 5) 6 3 1Use the following pseudocode:inRun = falseFor each valid index i in the arrayIf inRunIf values[i] is different from the preceding valuePrint ).inRun = falseIf not inRunIf values[i] is the same as the following valuePrint (.inRun = truePrint values[i].If inRun, print ). Please do in Java