1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
elixir [45]
2 years ago
5

Write a C++ console program to do the following: 1. Define an array of ints with the ten elements { 0, 1,2,3, 4, 5, 6, 7, 8, 9 }

. 2. Define a vector with those ten elements. 3. Define a list with those ten elements. 4. Define a second array, vect
Computers and Technology
1 answer:
Gemiola [76]2 years ago
7 0

Answer:

#include<iostream>

#include <vector>

#include <list>

using namespace std;

int main(){

int a[10]={0,1,2,3, 4, 5, 6, 7, 8, 9 };

std::vector<int> v (&a[0],&a[0]+10);

std::list<int> l (&a[0],&a[0]+10);

int b[10];

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

b[i]=a[i];

}

std::vector<int> v2(v);

std::list<int> l2(l);

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

b[i]+=2;

}

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

v2[i]+=3;

}

for (std::list<int>::iterator it = l2.begin(); it != l2.end(); it++)

*it=*it+5;

cout<<"Each containers value are: "<<endl;

cout<<"1st array: "<<endl;

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

cout<<a[i]<<" ";

}

cout<<"\n 1st vector: \n";

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

cout<<v[i]<<" ";

}

cout<<"\n 1st List is:\n";

for (std::list<int>::iterator it = l.begin(); it != l.end(); it++)

cout << *it << ' ';

cout<<"\n 2nd array: "<<endl;

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

cout<<b[i]<<" ";

}

cout<<"\n 2nd vector:\n";

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

cout<<v2[i]<<" ";

}

cout<<"\n 2nd list:\n";

for (std::list<int>::iterator it = l2.begin(); it != l2.end(); it++)

cout << *it << ' ';  

return 0;

}

Explanation:

  • Initialize an array, a vector and a list of type integer .
  • Create a 2nd array, vector, and list as a copy of the first array, vector, and list.
  • Increase the value of each element in the array by 2 , vector by 3 and list by 5.
  • Finally display the relevant results.
You might be interested in
How do you find a single number or name you want in a
Tamiku [17]

Answer:

The answer to this question is given below in the explanation section.

Explanation:

You can find a single number or name in a large worksheet containing thousands of numbers and names using the find and replacement feature in excel.

You can use Ctrl+F keyboard shortcut for finding and replacing features. When you press Ctrl+F, a dialog will get open, using this dialog, you can find the required number or name while entering in the search text box. Then, click on the Find button, if the worksheet matches the result, give you the matched result in the yellow highlighted color.

Also, you can use Ctrl+F to replace a name or number with some other name or number.

Alternatively, you can do this using the home tab, then find the option find and select under the editing group of commands.

8 0
3 years ago
Write a public static method diagSum, which takes a 2d array of int values as a parameter, and returns the sum of the elements i
saveliy_v [14]

A 2d array (i.e. 2 dimensional array) represents its elements in rows and columns

<h3>The program in Java</h3>

The method in Java, where comments are used to explain each line is as follows

//This defines the method

public static int diagSum(int[][] myArray) {

    //This initializes sum to 0

    int sum = 0;

    //This iterates through each row of the array

               for (int i = 0; i < myArray.length; i++) {

                   //This calculates the sum of the diagonals

                       sum+=myArray[i][i];

               }

               //This returns the sum

               return sum;

       }

Read more about methods at:

brainly.com/question/15969952

6 0
2 years ago
Windows needs free space on the hard drive for normal operation, for defragmenting the drive, for burning CDs and DVDs, and for
REY [17]

Answer:

True

Explanation:

Windows writes temporary files to the hard disk which it uses as a cache during normal operation. These files are usually deleted automatically after the windows operation has been completed. If there is no free disk space available, some windows operations will fail to start and others will stop working

3 0
2 years ago
Which of these categories of computer software can add thousands of dollars to the cost of a computer system?
Radda [10]
Specialized software. hope this helps
6 0
3 years ago
What stdio.h input function would be used to get input from the user by the keyboard? Write the code to obtain the voltage drop
torisob [31]

Answer:

scanf() function is used to get a input from keyboard.This function is in the stdio.h library.To use this function we must include the stdio.h library first in the code. Then only we can use the scanf() function in any code.printf() function is used to print anything .this function is from stdio.h library.

Code to read voltage drop across the register.

#include <stdio.h>

// main function

int main(void) {

// variable

double vr1;

printf("Enter voltage drop:");

// read  voltage drop from user

scanf("%lf",&vr1);

// print voltage drop

printf("voltage drop is:%0.2lf",vr1);

return 0;

}

Output:

Enter voltage drop:200.4                                                                                                  

voltage drop is:200.40

8 0
3 years ago
Other questions:
  • What information should be included in the closing paragraph of a thank-you letter? a. Mention skills that were omitted during t
    6·2 answers
  • The underwriters laboratories (ul) requirement for ? ground-fault circuit interrupters (gfcis) is that tripping shall occur when
    5·1 answer
  • There is a simple pattern for derermining if a binary number is odd. What is it and why does this pattern occur?
    8·1 answer
  • When a partition is formatted with a file system and assigned a drive letter it is called a volume?
    10·1 answer
  • Which of these components is a part of the Central Processing Unit (CPU) of a computer?
    11·2 answers
  • Does anyone know the answer for this? I’m extremely confused.
    8·2 answers
  • Favorite color should it be stored why?or why not?<br>​
    6·1 answer
  • We can use formatting before and after typing.​
    8·1 answer
  • The advancement of technology in our daily lives has changed how we interact with the world.
    10·1 answer
  • ________ helps in determining the cause of a security threat in an incident response plan. Question 7 options: A) Restricting sy
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!