Question #22581

write program that takes n numbers as input. it displays total positive and negative numbers.

Expert's answer

#include <conio.h>

#include <iostream>

using namespace std;

void main()

{

int n;

int number;

int positiveNumberCount = 0;

int negativeNumberCount = 0;

cout << "Enter the count of numbers: ";

cin >> n;

cout << "Enter " << n << " integer numbers:" << endl;

for (int c = 0; c < n; c++)

{

cin >> number;

if (number > 0)

positiveNumberCount++;

if (number < 0)

negativeNumberCount++;

}

cout << endl;

cout << "There is " << positiveNumberCount << " positive and " <<

negativeNumberCount << " negative number(s)." << endl;

getch();

}

#include <iostream>

using namespace std;

void main()

{

int n;

int number;

int positiveNumberCount = 0;

int negativeNumberCount = 0;

cout << "Enter the count of numbers: ";

cin >> n;

cout << "Enter " << n << " integer numbers:" << endl;

for (int c = 0; c < n; c++)

{

cin >> number;

if (number > 0)

positiveNumberCount++;

if (number < 0)

negativeNumberCount++;

}

cout << endl;

cout << "There is " << positiveNumberCount << " positive and " <<

negativeNumberCount << " negative number(s)." << endl;

getch();

}

## Comments

## Leave a comment