QUESTION 5 Given the code: srand(time(NULL)); int CAPACITY = 10; int a[CAPACITY]; Output Example 5 6 25 29 2689 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: QUESTION 5 Given the code: srand(time(NULL)); int CAPACITY = 10; int a[CAPACITY]; Output Example 5…
A:
Q: (Adding Large Integers) In C++, the largest int value is 2147483647. So, an integer larger than this…
A: Program Approach: Including necessary header files Declaring method readNumbers Declaring method…
Q: for a in range(9,15,1): How many times the loop statement will run? Write the output of the below…
A: Part 1) ------------------------ for a in range(9,15,1): Here this loop will run from a=9 to…
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: Declare three arrays: A, B and C each size 3 Read these numbers into A using for loop and scanf : 1,…
A:
Q: The Big One Remember that time when we tried identifying the largest digit among the given integer?…
A: Here I have taken input from the user and then created an array with the value inputted. Next, I…
Q: get started with the encoding program, start a new project and declare a character array that…
A: import java.util.*; class GFG { static int MAX = 26; static String printRandomString(int…
Q: to show ALL outputs. User need to key in data for "x", "y", and "?" area, x is refers single…
A: CODE:- #include<stdio.h> int main() { char x[3][3]; char y[3][3]; int i,j;…
Q: (Adding Large Integers) In C++, the largest int value is 2147483647. So, an integer larger than this…
A: Given: In C++, the largest int value is 2147483647. So, an integer larger than this cannot be…
Q: Given a sorted list of integers, output the middle integer. A negative number indicates the end of…
A:
Q: 7) The “off-by-one” error associated with arrays arises because a) the first array index is 0 and…
A: Please see the next step for solution
Q: Given the code: int a[10] = {1,2,3}; 1. Write a loop to print the array to the console. 2. Write…
A: Given the code:int a[10] = {1,2,3}; 1. Write a loop to print the array to the console.2. Write the…
Q: Write a program that prompts the user to read two integers and displays their sum. Your program…
A: As per Bartleby Guidelines: “Since you have asked multiple question, we will solve the first…
Q: Write statements to do the following: i. Write a loop that computes the sum of all elements in the…
A: Statement to find the sum of all the elements of an array named A. Declare the array named A…
Q: Rewrite the following loops, using the enhanced for loop construct. Here, values is an array of…
A: Enhanced for loop is used to iterate through elements of array. It’s also called for-each loop. This…
Q: a. Create a 1D array of Integers of size 10 to store 10 Integers from 1 to 10. b. Using the…
A: Answer: I have done code in java and also i have attached java code as well as code screenshot.
Q: 2) Read an integer input from the user and save it to a variable 'size'. - Use the variable 'size'…
A: Given, Read an integer from stdin and save it to a variable size which denotes some number of…
Q: ava: Arrays a1, a2… are populated as shown; display a[i] for each calls to arr; if a[i] less than…
A: Task : Given the array and the partial code. The task is to complete the code according to the…
Q: Step Use the scanner object to read an int from the user representing how many words you will read.…
A: Given:
Q: (Adding Large Integers) | In C++, the largest int value is 2147483647. So, an integer larger than…
A: A C++ program is as follows, //Header files #include <iostream> #include <string> using…
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: Use two-dimensional array with size 7 columns and 5 rows. 2. Seat numbers are populated during…
A: The above problem will make use of Scanner class defined under java.util package. It I used to take…
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: 5. Write a program that includes the following: a) Define a character array and initialize it with…
A: #include<stdio.h>int main(){ char s[]={'H','E','L','L','O'}; // define and initializing a…
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: Create two Arrays A with 10 unsorted integer elements and B with 10 unsorted float elements. Find…
A: NOTE: C++ is considered as a programming language to implement the question. To implement the…
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: 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: 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: Read in an integer n (n < 25). Read n integers in an array A. Then do the following (write separate…
A: Python Python includes the function sum(), which sums the numbers in the list. Syntax: sum…
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: 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: C. You have an array of size 300 byte stored in memory locations starting at 32000 H. Write a…
A: Answer :-
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 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: Write a block of code that uses a dynamic allocated array named Array to (1) Load ten integers from…
A: 1) Since programming language is not defined I have written program in C language 2) Below is…
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: mainc Tests Executions 4. Fill in the Gaps by CodeChum Admin E Run Tests The foundation for our…
A: C Code: #include<stdio.h> int main() { int i,j,n[9999],m,t; scanf("%d",&m);…
Q: A run is a sequence of adjacent repeated values. Write a program that generates a sequence of 20…
A: if previous value is same as current value, stay in run else no if current value is not same as next…
Q: Implement an empty integer array of capacity 5. a) Use a loop to input values from the console into…
A: #include <iostream> using namespace std; int main(){ //creating array int a[5];…
Q: Read in an integer n (n < 25). Read n integers in an array A. Then do the following (write separate…
A: Code: #include<stdio.h>#include <stdlib.h> int main() { int n; printf("Enter n…
Q: #include using namespace std; //swapping void swapping(int &a, int &b) { //variable…
A: The modified code without using function is written below:…
Q: Kindly write the following programs in DEV C++: - 1. Write a computer program to print the following…
A: As per our guidelines we are supposed to answer only one question. Kindly repost the remaining…
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…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 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