473,320 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

counting positive and negative numbers

i don't know the codes to count how many negative and positive.. can you help me with the codes to count negative and the positive numbers? here is my code i can't finish it yet 'cause i don't know the codes or the condition.. hehehe.. :D


Expand|Select|Wrap|Line Numbers
  1. #include <iostream.h>
  2.  
  3. main ()
  4.  
  5.     {
  6.         int x;
  7.         int count[100];
  8.  
  9.         cout << "Input 10 numbers: ";
  10.         for (x=0; x<10; x++)
  11.         cin >> count[x];
  12.     }
Nov 13 '15 #1
2 1290
weaknessforcats
9,208 Expert Mod 8TB
Just write a loop that goes from 0 to 99. Inside the loop check each element of the array to be positive using an "if" statement:

Expand|Select|Wrap|Line Numbers
  1. if (count[x] < 0)
  2. {
  3.    add to the negative total
  4. }
  5. else
  6. {
  7.  add to the positive total
  8. }
I'm not supposed to write the whole code for you.
Nov 13 '15 #2
donbock
2,426 Expert 2GB
By the way, what do you want to do for a value of zero, which is neither positive nor negative. I'm not suggesting there is a right or wrong answer to that question -- but you need to decide before you can write the code.
Nov 13 '15 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Mayank | last post by:
X-No-Archive: yes Hi, I have to replace all the negative numbers with 0 in a very large file. How can I do it in Perl/Awk. Negative numbers are of the format (-0.02:0.01:-1.00) (...
7
by: pj | last post by:
Why does M$ Query Analyzer display all numbers as positive, no matter whether they are truly positive or negative ? I am having to cast each column to varchar to find out if there are any...
11
by: tlyczko | last post by:
Hello Rob B posted this wonderful code in another thread, http://groups.google.com/group/comp.lang.javascript/browse_thread/thread/c84d8538025980dd/6ead9d5e61be85f0#6ead9d5e61be85f0 I could not...
39
by: Frederick Gotham | last post by:
I have a general idea about how negative number systems work, but I'd appreciate some clarification if anyone would be willing to help me. Let's assume we're working with an 8-Bit signed integer,...
1
by: twocansam1 | last post by:
I am writing a routine to check for bad or no input, How can I check for blanks or spaces and negative numers?? negative numbers and spaces just cause the program to lock up. They don't get...
20
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including...
5
by: vbgunz | last post by:
/* * BEGIN EXAMPLES */ var text = 'A Cats Catalog of Cat Catastrophes and Calamities'; /*** * EXAMPLE 1: negative lookahead assertion logic ***/
6
by: ariel ledesma | last post by:
hello guys i just ran into this when comparing negative numbers, they start returning False from -6 down, but only when comparing with 'is' True False True i read that 'is' compares if...
4
yosiro
by: yosiro | last post by:
I have a module to convert numbers (in positive value) into My Language (indonesian) words below: Option Compare Database Public Function ubah_terbilang(xbil As Double) Dim nilai, i, j, k,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.