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
gayaneshka [121]
4 years ago
9

Create a C++ program that declares, initializes, and outputs the values contained in a two-dimensional array

Computers and Technology
1 answer:
Kazeer [188]4 years ago
8 0

Answer:

// here is code in C++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{

// variables

int r_size,c_size;

cout<<"enter the number of row:";

// read the value of row

cin>>r_size;

cout<<"enter the number of column:";

// read the value of column

cin>>c_size;

// create a 2-d array

int arr[r_size][c_size];

// read the value of array

cout<<"enter the elements of array:"<<endl;

for(int x=0;x<r_size;x++)

{

for(int y=0;y<c_size;y++)

{

cin>>arr[x][y];

}

}

cout<<"elements of the array are:"<<endl;

// print the array

for(int a=0;a<r_size;a++)

{

for(int b=0;b<c_size;b++)

{

cout<<arr[a][b]<<" ";

}

cout<<endl;

}

return 0;

}

Explanation:

Here we have demonstrate a 2- dimensional array. In which, how to read the elements and how to print elements of array.Read the value of row and column from user.Create a 2-d array of size r_sizexc_size. then read the elements of array either row wise or column wise. Then print the elements.To print the elements, we can go either row wise or column.

Output:

enter the number of row:2

enter the number of column:3

enter the elements of array:

1 2 3

2 3 4

elements of the array are:

1 2 3

2 3 4

You might be interested in
What permissions should you assign a group if you want the group to have the ability to read, add, delete, execute, and modify f
ratelena [41]

Answer:

Modify is the correct answer to the following question.

Explanation:

If any person or user wants to read, delete, modify and execute the files then they have required the Modify permission. In other words, Modify permission provides the user to modify and delete the following files but they unable to delete subfolders because of the following permission.  

If they want then they have to change the permission by click right button from the mouse on the file or the folders which they want to change and then click on the properties from there they can change the permission.

7 0
4 years ago
Write a function DrivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar
stira [4]

Answer:

// program in C++.

#include <bits/stdc++.h>

using namespace std;

// function to calculate cost

double DrivingCost(double drivenMiles, double milesPerGallon, double dollarsPerGallon){

  double cost;

  //Expression to compute cost

  cost = drivenMiles / milesPerGallon * dollarsPerGallon;

  return cost;

}

// main function

int main()

{

   double drivenMiles, milesPerGallon, dollarsPerGallon;

  //initialise the variables

  drivenMiles = 50;

  milesPerGallon = 20.0;

  dollarsPerGallon = 3.1599;

  //Call function

  double cost = DrivingCost(drivenMiles,milesPerGallon,dollarsPerGallon);

  //Display result

  cout<<"Driven miles : "<<drivenMiles<<endl;

  cout<<"Miles per Gallon : "<<milesPerGallon<<endl;

  cout<<"Dollars per Gallon : "<<dollarsPerGallon<<endl;

  cout << fixed << setprecision(2);

  cout<<"The total driving cost : "<<cost ;

  return 0;

}

Explanation:

Declare and initialize drivenMiles with 50, milesPerGallon with 20.0 and dollarsPerGallon with 3.1599.Call the function DrivingCost() with these parameters,This will calculate the cost and return the value.Print the result after getting the cost.Similarly we can calculate cost for drivenMiles equals to 10 and 400 miles also.

Output:

Driven miles : 50

Miles per Gallon : 20

Dollars per Gallon : 3.1599

The total driving cost : 7.90

5 0
3 years ago
You have a network that uses a logical ring topology. how do messages travel through the network"
RSB [31]
Messages travel from one computer to another until they will find a proper computer to whom that message is addressed.
7 0
3 years ago
In the central processing unit (CPU).
mr Goodwill [35]
<h3>Answer : B.responsible for the logical order of processing and converting daya</h3>

<h3>Reason</h3>

As i said bro, in CPU there are ALU and CU where ALU is to do mathematics problem and CU where its to processing, converting data. CPU is like the brain of computer. But it can't be the input, the input can get through hardware, not CPU.

4 0
3 years ago
You can use a 32-bit processor to install the hyper-v role as long as it supports virtualization extensions. true or false
Ainat [17]
No, that is false. :)
3 0
4 years ago
Other questions:
  • Which connector is most commonly used to connect printers to desktop pc systems?
    10·1 answer
  • Why is sequencing important in coding
    8·2 answers
  • What differences in traffic patterns account for the fact that STDM is a cost-effective form of multiplexing for a voice telepho
    10·1 answer
  • Write algorithm to find (a+b)^2=(a+b)*(a+b)​
    9·1 answer
  • Which of the following is true regarding a class and interface types? Group of answer choices You can convert from a class type
    9·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    7·1 answer
  • Earth's current era is the _______ era.
    9·2 answers
  • What is kerning in Adobe Indesign
    7·1 answer
  • HURRY HELP THIS IS FOR CODING !!!! What are some real-life situations that require a program that is iterative? Include at least
    6·2 answers
  • In the range D5:D9 on all five worksheets, Gilberto wants to project next year's sales for each accessory, rounded up to zero de
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!