# Answer to Question #18857 in C++ for aisha

Question #18857

Write a C++ program that inputs 20 floating-point values from the keyboard and

outputs:

a) The number of values that are negative

b) The number of values that are zero

c) The number of values that are positive.

Notes: For example, the output might be 7,3,10 meaning that there are 7 negative

values, 3 values that are zero, and 10 values that are positive.

outputs:

a) The number of values that are negative

b) The number of values that are zero

c) The number of values that are positive.

Notes: For example, the output might be 7,3,10 meaning that there are 7 negative

values, 3 values that are zero, and 10 values that are positive.

Expert's answer

#include <iostream>

#include <conio.h>

using namespace std;

int main()

{

int arrayofnumbers[20];

int countfornegative=0;

int countforzero=0;

int countforpositive=0;

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

cout<<"Enter number "<<(i+1)<<": ";

cin>>arrayofnumbers[i];

}

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

if(arrayofnumbers[i]<0){

countfornegative++;

}

if(arrayofnumbers[i]==0){

countforzero++;

}

if(arrayofnumbers[i]>0){

countforpositive++;

}

}

cout<<"

The number of values that are negative

"<<countfornegative;

cout<<"

The number of values that are zero

"<<countforzero;

cout<<"

The number of values that are positive

"<<countforpositive;

cout<<"

Press any key to exit...";

getch();

return 0;

}

#include <conio.h>

using namespace std;

int main()

{

int arrayofnumbers[20];

int countfornegative=0;

int countforzero=0;

int countforpositive=0;

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

cout<<"Enter number "<<(i+1)<<": ";

cin>>arrayofnumbers[i];

}

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

if(arrayofnumbers[i]<0){

countfornegative++;

}

if(arrayofnumbers[i]==0){

countforzero++;

}

if(arrayofnumbers[i]>0){

countforpositive++;

}

}

cout<<"

The number of values that are negative

"<<countfornegative;

cout<<"

The number of values that are zero

"<<countforzero;

cout<<"

The number of values that are positive

"<<countforpositive;

cout<<"

Press any key to exit...";

getch();

return 0;

}

## Comments

## Leave a comment