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
Bogdan [553]
3 years ago
8

Assume you are given a boolean variable named isNegative and a 2-dimensional array of ints that has been created and assigned to

a2d. Write some statements that assign true to isNegative if more integer elements in entire 2-dimensional array are negative than not.
Computers and Technology
1 answer:
Anon25 [30]3 years ago
5 0

Answer:

#include <iostream>

using namespace std;

int main(){

   int rows, cols;

   bool isNegatives;

   cout<<"Rows: ";

   cin>>rows;

   cout<<"Columns: ";

   cin>>cols;

   int a2d[rows][cols];

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

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

       cin>>a2d[i][j];}    }

   int negatives, others = 0;

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

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

       if(a2d[i][j]<0){

           negatives++;}

       else{

           others++;}}    }

   if(negatives>others){

       isNegatives = true;}

   else{

       isNegatives = false;}

   cout<<isNegatives;  

   return 0;

}

Explanation:

For clarity and better understanding of the question, I answered the question from the scratch.

This line declares number of rows and columns

   int rows, cols;

This line declares the Boolean variable

   bool isNegatives;

This line prompts user for rows

   cout<<"Rows: ";

This line gets the number of rows

   cin>>rows;

This line prompts user for columns

   cout<<"Columns: ";

This line gets the number of columns

   cin>>cols;

This line declares the array

   int a2d[rows][cols];

This line gets user input for the array

<em>    for(int i =0;i<rows;i++){</em>

<em>    for(int j =0;j<cols;j++){</em>

<em>        cin>>a2d[i][j];}    }</em>

This line declares and initializes number of negative and others to 0

   int negatives, others = 0;

The following iteration counts the number of negatives and also count the number of non negative (i.e. others)

<em>    for(int i =0;i<rows;i++){</em>

<em>    for(int j =0;j<cols;j++){</em>

<em>        if(a2d[i][j]<0){</em>

<em>            negatives++;}</em>

<em>        else{</em>

<em>            others++;}}    }</em>

This checks of number of negatives is greater than others

   if(negatives>others){

If yes, it assigns true to isNegatives

       isNegatives = true;}

   else{

If otherwise, it assigns false to isNegatives

       isNegatives = false;}

This prints the value of isNegatives

   cout<<isNegatives;  

<em>See attachment</em>

Download cpp
You might be interested in
A group of users is unable to connect to the network. When testing several of the PCs and issuing the command ipconfig, the tech
Juliette [100K]
D is the right answer because DNS is the answer
5 0
3 years ago
An alteration threat violates information integrity. <br> a. True <br> b. False
Art [367]
The answer is True


It intentionally or unintentionally compromises a system by making unauthorized changes to data. As compared to intentional changes which are usually malicious, unintentional changes are normally accidental. Changes and modifications to the system configurations can also compromise integrity. Such modifications might include deleting, changing, and creating information in a network resource. It is best to implement mechanisms on how one can track and audit such changes as they happen




6 0
3 years ago
On most computers, the default font size in Word is ____. 8 11 14 16
julsineya [31]
The font size depends on how the computer can handle font size or the monitor's size.
Mostly, it's 16.

To move one up paragraph, it's +UP ARROW
8 0
3 years ago
WHICH COMPUTER COMPONENT CONTAINS ALL THE CIRCUITRY NECESSARY FOR THE OTHER COMPONENTS OR DEVICES TO COMMUNICATE WITH ONE ANOTHE
netineya [11]
I'm pretty sure it's the motherboard. You shouldn't use all caps. It makes it seem like you are shouting, and less people want to answer. :)
7 0
3 years ago
For her homework, Annie has added the picture of a fruit in a document. She wants to enhance it to give a cut-out look. Which fe
Kaylis [27]

Answer:

Explanation:

We must follow several steps:

  1. We must click in the image
  2. Click Image Tools > Format
  3. Click the date under Crop
  4. We must resize the image, or Trim one side, Trim two adjacent sides, Trim the same fragment.
  5. Click the Crop button again if you finished

In addition, we can change the form of the image, we have a lot of options in crop to shape.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which one is a run-on sentence? you get mark the brilist
    5·2 answers
  • An information security ________ is a specification of a model to be followed during the design, selection, and initial and ongo
    11·2 answers
  • Which buttons should you use to publish and change a message on a message board
    6·2 answers
  • 1. Itemise the order in which BASIC executes arithmetic operation.
    13·1 answer
  • Which best describes a hybrid drive?
    11·1 answer
  • 5. Which one of the following statements is true for spell checkers? A. Most spell checkers flag inappropriate word usage. B. A
    5·1 answer
  • The lower band and upper band of integer data type​
    6·1 answer
  • You have a team member on a remote project who is not fluent in English and
    15·1 answer
  • Explain any two types of board band connection​
    11·1 answer
  • Difference between centralized and decentralized processing in computer
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!