Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
expand_more
expand_more
format_list_bulleted
Bartleby Related Questions Icon
Related questions
Question
Transcribed Image Text:Implement a program that will populate a 6x5 matrix with randomly generated
integers from 100 to 500.
(1) print your matrix in a table form.
(2) modify your code to multiply all odd numbers by 2 and print the matrix.
Sample run:
Initial Matrix:
145 | 437 | 222 | 101 | 100 |
278 500 | 190 | 415 | 288 |
466 322 377 | 240 | 451 |
331 186
186
432
102 | 106 |
105 249
248 | 117 | 213 |
499 488
355 | 266 | 396 |
New Matrix:
290 | 874 | 222 | 101 | 100 |
278
500 | 190 | 830 288 |
466 322
754 | 240 | 902 |
662 186
432 | 102 | 106 |
210| 498
248 | 234 | 426 |
998 488 710 | 266 | 396 |
Expert Solution
Check Markarrow_forward
C program code for to populate randomly generated integers
Solution
C program code for to populate a matrix with 6 X5 randomly generated integers from 100 to 500
rand(): It is a C library function. which is used to return the pseudo random number with in a range.
1) Print it in a table form
C program code
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i,j;
printf("Initial Matrix :\n\n");
for(i=0;i<6;i++){
for(j=0;j<5;j++){
printf("%d ",rand()%(500-100+1)+100);
printf("|");
}
printf("\n");
}
}
Screenshot
Computer Science homework question answer, step 1, image 1
Computer Science homework question answer, step 1, image 2
bartleby
Step by stepSolved in 2 steps with 4 images
Knowledge Booster
Background pattern image
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
- Make a program that creates and displays a 5x10 matrix(5 rows and 10 columns) of random integers between 1 and a maximum value(user input). Hint: Use the random library to generate each number and place it into your 2D list. The program then counts the number of prime numbers in each row of the array and displays this number, along with the found primes. The program finally displays the total number of prime numbers in the matrix.arrow_forwardWrite a program in c that create a 5-by-6 array. All elements in the array are random integer numbers between 1 and 100. Then, calculate the mean values of each column, and also find the minimums and maximums of each column. Print out the array, mean values, minimums,arrow_forwardCreate a program that will encrypt letters and create a secret code. You will create an array of numbers from 0 - 25. use [i for i in range (26)] to create an array of numbers from 0 - 25. use random.shuffle to to shuffle the above array. This will be used for a new letter index order. For example: The first created array [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25] gets shuffled to become[2, 14, 12, 20, 16, 5, 11, 1, 13, 17, 15, 21, 19, 10, 23, 22, 25, 3, 6, 7, 18, 4, 9, 24, 0, 8] This will be used as the new index for the encrypted alphabet. create an array of letters using list(string.ascii_lowercase), this requires importing the string module. This will create: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] Accept an input of a word. Using the above tables take each letter of the word and convert it to the encrypted letter. Print each...arrow_forward
- Write in Java. Write a function to read elements of a N by N, 2 dimensional (2D) array and display the 2D array in a matrix form and find the first row and column with the most 1s. Input: 4 0 0 1 1 0 0 1 1 1 1 0 1 1 0 1 0 Where, First line of represents n, the number of rows and columns. Second line contains array elements of the 1st row and so on. Output: 0 0 1 1 0 0 1 1 1 1 0 1 1 0 1 0 2 2 where, There must be single space between 2 numbers in the row. There should not be any space after the last number in the row. e.g. in the last row, there should not be any space after number 0. The first number bellow the matrix is the index of the first row with the most 1s and the second number is the index of the first column with the most 1s. There should not be any space after the second number (the index of the first column with the most 1s). Assume that, Row and column values are integers within the range [1 to 100]. 2D Array elements are within the range [0 to 1].arrow_forwardCan you please write a code in java language?arrow_forwardAn array is declared as short Lot[67]. The address of Lot is 0x2877. What is the address of Lot[40]? Give your answer in 4 hexadecimal digits (include leading zeros). An array is declared as int State[29]. The address of State is 0xF988. What is the address of State[21]? Give your answer in 4 hexadecimal digits (include leading zeros). An array is declared as short Night[29]. The address of Night is 0xBE47. What is the address of Night[26]? Give your answer in 4 hexadecimal digits (include leading zeros).arrow_forward
- in java ecplise . Implement a program that randomly generates 10 integers from -100 to 100,stores them in a 1D array, and finds their maximum value. Calculate theexecution time of finding a maximum. Repeat the test for 10,000 and10,000,000 numbers. Provide your results in the form of a table below andprovide a small summary. Implement a Java program that will populate a 5x5 matrix with randomlygenerated integers from 0 to 100.(1) print your matrix in a table form.(2) modify your code to multiply all even numbers by 10 and print the matrix.Your output of questions (1) and (2) should match the format of the followingsample outputs:arrow_forwardimport numpy as np a = np.array([1,2,3]) b = np.array([4,5,6]) You may need to use NumPy methods to answer the following questions. What is the cross product of the two vectors a and b given above? What is the dot product of the two vectors a and b given above?arrow_forwardWrite a function that takes a one-dimensional array and its size [10], and then fill each location in the array by the cubic of the location's index. To cube the location's index write your function int cube(int x). Then print out your array. Consider the following three functions in your program: int cube(int x). • void fillArray(int [], int size). • void printArray(int [], int size). Sample input / output: The generated array is: 0 1 8 27 64 125 216 343 512 729arrow_forward
- Write a program that prompts the user for an integer, then asks user to enter that many integer value. Store these values in an integer array and print the array. Reverse the array elements so that first element become the last element, the second element become the second to last element, and so on, with the old last element now first. Do not just reverse the order in which they are printed; actually, change the way they are stored in the array. Try not to create a second array; just rearrange the elements within the array you have. (Hints; Swap elements that need to change place.) When the elements have been reversed, Print the array again.arrow_forwardUsing JAVA, write a method that swaps two rows of a two-dimensional array. The row indices to be swapped are passed as parameters to the method (Assume row indices are valid indices). Write a test program to demonstrate correct operation of the method.arrow_forwardWrite an c progra, that takes an array of N integers (N will be specified by the user at run time). It then finds how many numbers in the array are divisible by 3 and how many numbers are divisible by 7. the it copies, from the input array above, the numbers that are divisible by 3 into a new array and those divisible by 7 into a different new array. Once copied, the algorithm should compute the average of each of these two new arrays and print the averages on the screen with suitable message to let the user know which average is being printed Note: an integer number is divisible by 3 (respectively 7) if the remaining of its division by 3 (respectively 7) is 0. You are allowed to use the modulus operator %.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education