Question

Language:C++ If a user inputs number in the form below, i need help storing the first...

Language:C++

If a user inputs number in the form below, i need help storing the first element of each row in an array and the second element of each row in a separate array

1 2

3 4

5 6

arrray 1 = {1,3,5}

array 2 = {2,4,6}

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    int arr1[3], arr2[3];
    cout << "Enter a 3x2 input: ";
    for (int i = 0; i < 3; ++i) {
        cin >> arr1[i] >> arr2[i];
    }
    // print first array
    for (int i = 0; i < 3; ++i) {
        cout << arr1[i] << " ";
    }
    cout << endl;
    // print second array
    for (int i = 0; i < 3; ++i) {
        cout << arr2[i] << " ";
    }
    cout << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
Language:C++ If a user inputs number in the form below, i need help storing the first...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I'm a little crunched for time and need some help with these first two questions. Thank...

    I'm a little crunched for time and need some help with these first two questions. Thank you! Question 1.) Write a Java program that reads in sequence of integers from the user until user enters a negative number and stores them in an Integer ArrayList. Once read, display a bar chart based on the values stored in the ArrayList. For example, if the user inputs 2, 5, 3, 8, 4, and -1, then your program should display the bar chart...

  • I just need some matlab help and assistance Refresher 1. Create a vector called A containing...

    I just need some matlab help and assistance Refresher 1. Create a vector called A containing 1, 2, 3,4, and 5 2. Create a vector called B containing 6,7, 8, 9, and 10 . Combine A and B to create an array called C where A is the first row and B is the second row 4. Find the 7th element in C 5. Determine the location of 8' in array C

  • I need help asking the user to half the value of the displayed random number as...

    I need help asking the user to half the value of the displayed random number as well as storing each number generated by the program into another array list and displayed after the game is over at the end java.util.*; public class TestCode { public static void main(String[] args) { String choice = "Yes"; Random random = new Random(); Scanner scanner = new Scanner(System.in);    ArrayList<Integer> data = new ArrayList<Integer>(); int count = 0; while (!choice.equals("No")) { int randomInt =...

  • PYTHON CODING HELP: BELOW ARE THE STEPS I NEED HELP WITH PLEASE. :) First create a...

    PYTHON CODING HELP: BELOW ARE THE STEPS I NEED HELP WITH PLEASE. :) First create a text file named "items.txt" that has the following data in this order: Potatoes Tomatoes Carrots ... and have it be in the same directory as the Python program you are coding for this assignment. IMPORTANT: Your program should work with any size file. It should work with 100 items listed or with no items in the file! Write a Python program that ... 1....

  • I need help as quick as possible, thanks beforehand. Please provide the test output The Lo...

    I need help as quick as possible, thanks beforehand. Please provide the test output The Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. 35 The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 - 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: 15 4 92 15 - 81 + 15 15 15...

  • this assignment need to be done in java only Requirements: Ask the user to enter the...

    this assignment need to be done in java only Requirements: Ask the user to enter the size of an array (int value) Allocate a 2D array of int that size (if the user enters in 5, then allocate a 5x5 array) Using a Random, initialize each element of the array to be either 0 or 1 Output the array in a table format (see below for an example) Output the fraction of your array that is ones and the fraction...

  • I need help with the C++ for the following problem: Write a program that can store...

    I need help with the C++ for the following problem: Write a program that can store and output 5 integers, where the user can input its value into an array named arrayValue. The program should implement the following: 1. Calculate the sum and average of the array. 2. Output the content (value) that stored in the array of five elements. 3. Continue to ask the user to store for storing data into another array.

  • Write a Java application that prompts the user for pairs of inputs of a product number...

    Write a Java application that prompts the user for pairs of inputs of a product number (1-5), and then an integer quantity of units sold (this is two separate prompts for input values). You must use a switch statement and a sentinel-controlled loop (i.e. a loop that stops execution when an out of range value, such as -1, is input). All 15 items below are for a single purchase. There are five sets of inputs as follows: Product 1    1...

  • C++ Random number generation in a loop plus storing it as the min or max number?...

    C++ Random number generation in a loop plus storing it as the min or max number? I'm new to C++ and have an assignment in which I need to create a calculator using a loop and random numbers. The idea is to have the user will input a number as the upper bound. The user then inputs the amount of loops they want to run. This has to be greater than 3. Each time a number is generated, it has...

  • Create a java class that user put two inputs and first input generate n length array...

    Create a java class that user put two inputs and first input generate n length array of randomly generated numbers. and the second input changes that number of multiples in the array into zero. for example, if the user puts 3 and 5 then it generates 34 60 10 and since the second input is 5 then the multiple of 5 eliminates so it generates 34 0 0 here is the main method that I'm going to use class Main...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT