Question

In: Computer Science

Write a program in c++ that reads x[4]. Then create the array y[6||6], such that the...

Write a program in c++ that reads x[4]. Then create the array y[6||6], such that the first quarter of y consists of the value of the first element of x. The second quarter of y consists of the value of the second element of x. The third quarter of y consists of the value of the third element of x. The fourth quarter of y consists of the value of the fourth element of x?

Solutions

Expert Solution

#source code in c++:

#include <iostream>

using namespace std;

int main(){

int x[4],y[6][6];

for(int i=0;i<4;i++){

cout<<"Enter Element x"<<(i+1)<<" :";

cin>>x[i];

}

for(int i=0;i<6;i++){

for(int j=0;j<6;j++){

if(i<3 && j<3){

y[i][j]=x[3];

}else if(i<3 && j>=3){

y[i][j]=x[0];

}else if(i>=3 && j<3){

y[i][j]=x[2];

}else if(i>=3 && j>=3){

y[i][j]=x[1];

}

}

}

for(int i=0;i<6;i++){

for(int j=0;j<6;j++){

cout<<y[i][j]<<" ";

}cout<<endl;

}

return 0;

}

#output:

#if you have any doubt or more information needed comment below..i will respond as possible as soon...thanks...


Related Solutions

c++ language Create a file program that reads an int type Array size 10; the array...
c++ language Create a file program that reads an int type Array size 10; the array has already 10 numbers, but your job is to resize the array, copy old elements of array to the new one and make it user input and add an additional 5 slots in the array, and lastly do binary search based on user input. close the file.
Write a Java program that reads a list of integers into an array. The program should...
Write a Java program that reads a list of integers into an array. The program should read this array from the file “input.txt”. You may assume that there are fewer than 50 entries in the array. Your program determines how many entries there are. The output is a two-column list. The first column is the list of the distinct array elements; the second column is the number of occurrences of each element. The list should be sorted on entries in...
Directions: Write a C++ program that will create an array of four integers. It will allow...
Directions: Write a C++ program that will create an array of four integers. It will allow the user to enter in four valid scores and store them in the array. ( valid range is 0 - 100) It will compute the letter grade based upon the four scores, namely, A = 90 - 100, B= 80- 89, C = 70-79, D = 60-69, otherwise F. It will display the scores and letter grade to the screen. NOTE: No menu is...
IN C LANGUAGE This program reads a threshold, a size, and an array of integers. The...
IN C LANGUAGE This program reads a threshold, a size, and an array of integers. The program then calls the foo function. The function will modify the array x of size n by doubling any values in x that are less than the threshold. The function will count how many values were changed and how many were not changed via two reference parameters. The function signature is: void foo(int n, int x[], int threshold, int *pChanged, int *pUnchanged); The function...
How do I create this program? Using C++ language! Write a program that reads data from...
How do I create this program? Using C++ language! Write a program that reads data from a text file. Include in this program functions that calculate the mean and the standard deviation. Make sure that the only global varibles are the mean, standard deviation, and the number of data entered. All other varibles must be local to the function. At the top of the program make sure you use functional prototypes instead of writing each function before the main function....ALL...
Write a program in c++ to do the following: 2. Create an array to hold up...
Write a program in c++ to do the following: 2. Create an array to hold up to 20 integers. 3. Create a data file or download attached text file (twenty_numbers.txt) that contains UP TO 20 integers. 4. Request the input and output file names from the user. Open the files being sure to check the file state. 5. Request from the user HOW MANY numbers to read from the data file, up to twenty. Request the number until the user...
Project 6-1: Email Creator C++ code Create a program that reads a file and creates a...
Project 6-1: Email Creator C++ code Create a program that reads a file and creates a series of emails. Console Email Creator ================================================================ To:      [email protected] From:    [email protected] Subject: Deals! Hi James, We've got some great deals for you. Check our website! ================================================================ To:      [email protected] From:    [email protected] Subject: Deals! Hi Josephine, We've got some great deals for you. Check our website! ================================================================ To:      [email protected] From:    [email protected] Subject: Deals! Hi Art, We've got some great deals for you. Check our website! Specifications...
Program in C: Write a program in C that reorders the elements in an array in...
Program in C: Write a program in C that reorders the elements in an array in ascending order from least to greatest. The array is {1,4,3,2,6,5,9,8,7,10}. You must use a swap function and a main function in the code. (Hint: Use void swap and swap)
in C++, Write a program that asks the user to enter 6 numbers. Use an array...
in C++, Write a program that asks the user to enter 6 numbers. Use an array to store these numbers. Your program should then count the number of odd numbers, the number of even numbers, the negative, and positive numbers. At the end, your program should display all of these counts. Remember that 0 is neither negative or positive, so if a zero is entered it should not be counted as positive or negative. However, 0 is an even number....
Write a program that initializes an array of 6 random integers and then prints 4 lines...
Write a program that initializes an array of 6 random integers and then prints 4 lines of output, containing the following: 1. Only the first and last element 2. Every element at an odd index 3. Every odd element 4. All elements in reverse order
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT