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
Sam would like to install a new application on every computer in his SOHO network. All the computers are currently connected in
lisabon 2012 [21]

Let us assume that Sam has an Active Directory Domain in his SOHO network.  He can use features that come with an AD domain to deploy software packages via Group Policy Objects. These features from Microsoft not only give us simple ways to deploy software, but also provide solutions to uninstall too. Another option to consider using is through 3rd party software solutions like PDQ Deploy. This tool will help deploy any Windows application to multiple PCs in the same workgroup.

4 0
4 years ago
By default, the hyperlink will display the text in the hyperlink itself, such as the web URL. How can this behavior be modified?
Arte-miy333 [17]

Answer:

Text to display

3 0
3 years ago
Which term describes an approach to security similar to defense in depth in that it supports multiple layers, but uses a differe
miss Akunina [59]

Answer:

The answer to this question is Diversity of Defense.

Explanation:

Diversity of defense:- It is an approach for security which supports multiple layers but the catch here is that at each layer a different mechanism of security is used or at most of the layers.The idea is that you do not need to have multiple layers of defense but different defenses also.  

So we conclude that the answer to this question is Diversity in Defense.

3 0
3 years ago
The communication channel used in IMC must rev: 12_06_2018_QC_ CDR-223 Multiple Choice match the traditional channel used in tha
Setler [38]

Answer:

connect the sender with the desired recipients.

Explanation:

Integrated Marketing Communication (IMC) is a process through which organizations create seamless branding and coordination of their marketing and communication objectives with its business goals and target audience or consumers. The communication tools used in IMC are both digital and traditional media such as billboards, search engine optimization, magazines, television, blog, radio, webinars etc.

The communication channel used in IMC must connect the sender with the desired recipients.

The receiver is any individual who is able to read, hear or see and process the message being sent or communicated in the IMC communication process. Any interference the IMC communication process is known as noise.

An organization can analyze and measure the effectiveness of the IMC communication process by considering market share, sales, and customer loyalty.

5 0
3 years ago
Anomaly detection systems make use of _______________ that describe the services and resources each authorized user or group nor
zhuklara [117]

Answer:

profiles

Explanation:

<h2><u>Fill in the blanks </u></h2>

Anomaly detection systems make use of <u> profiles</u> that describe the services and resources each authorized user or group normally accesses on the network.

5 0
3 years ago
Other questions:
  • GenXTech is a growing company that develops gaming applications for military simulations and commercial clients. As part of its
    8·1 answer
  • Pls help is very urgent and I will mark u as brainliest plsssss​
    11·2 answers
  • Select the correct answer. One of the functions of a data warehouse is to change table names to meaningful names. Which name is
    13·1 answer
  • Which commands can be used to highlight a whole paragraph? Check all that apply.
    6·1 answer
  • A cookie filter blocks the sending and receiving of cookies. Blocking cookies can reduce some threats of session tracking and id
    12·1 answer
  • In Linux, users are internally represented using a unique number called user ID or uid.
    9·1 answer
  • Suppose end system A wants to send a large file to end system B. At a very high level, describe how end system A creates packets
    9·1 answer
  • Laura is filming a scene in which the subject is sitting with a lit fireplace behind him. The only other source of light in the
    5·1 answer
  • Explain the risks to privacy from collecting and storing personal data on computer systems and the programmer’s role to safeguar
    11·1 answer
  • Element of python which is valid syntax patterns
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!