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]
2 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]2 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
Instagram
Aleonysh [2.5K]
Uninstall instagram and install it again. log in and go to settings and fix up the notifications maybe that’ll work??

if it doesn’t, go to your apple settings and see if the notifications for instagram are on.

also try shutting your phone off for a few seconds if you do either one.
5 0
3 years ago
What are two types of organizational structures designed to help an organization achieve its goals and objectives?
Fittoniya [83]

The answer is entrepreneurial and bureaucratic. Organizations that are large and small can achieve higher sales and other profit by properly matching their needs with the structure they use to operate.   the structure of an organization can help or hinder its progress toward accomplishing these goals and This are specific set up of organizations and ways to accomplish different goals. 

4 0
3 years ago
Read 2 more answers
Select the most likely outcome of making only on-time minimum payments to a credit
Serjik [45]
The answer is B. Your will have gone mostly towards paying interest and you will still owe the majority of the balance that you had from ago
4 0
3 years ago
Select the correct answer.
Crank

Answer:

Sensing elements.

Explanation:

Sensing elements are the device which connect channels feedback and return it to the control system input. There are many sensors used for feedback control such as Tachometer, Encoders, Accelerometers and rate gyroscopes.

3 0
3 years ago
What would be the most popular piece of technology on Earth?
spin [16.1K]

Answer:

the smart phone

Explanation:

It is the most widley used and accepted

8 0
3 years ago
Read 2 more answers
Other questions:
  • As in algebra, you can use brackets to override the order of operations Excel follows to perform formula calculations. True or f
    13·1 answer
  • Henry, a graphic artist, wants to create posters. Which software should Henry use for this purpose?
    13·1 answer
  • Danielle, a help desk technician, receives a call from a client. In a panic, he explains that he was using the Internet to resea
    8·1 answer
  • When mapping a drive, you can type in the path to the shared folder on the host computer. what is the syntax for the path?
    7·1 answer
  • Your source data is of 50 GB. You make a full backup. Next week, once again you perform a full backup, but this time 10 more GB
    10·1 answer
  • I need help with workplace safety systems please help
    10·1 answer
  • Write a program named RectangleArea to calculate the area of a rectangle with a length of 15.8 and a width of 7.9. The program s
    10·1 answer
  • Please be my friend. my best and only friend isn't talking to me for some reason
    9·2 answers
  • g How safe is to have a LinkedIn account where you have published all the important information about yourself
    13·2 answers
  • An online bank wants you to create a program that shows prospective
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!