473,386 Members | 1,908 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,386 software developers and data experts.

How to selectively choose only numbers greater that 1000 in the array to be used

Hi, I am an engineering student who just started my first C++ module. I am doing my assignment that will calculate total tax amount per day and per week and finally sum those up.

One of the requirement is to filter out any number in the array that is less than 1000 to be assigned a value of zero instead of the stored value so as not to add it in the calculation. I have no idea how to fulfill this requirement. Can anyone kindly help me with this? This is the code I have so far.
Aug 4 '13 #1

✓ answered by weaknessforcats

You have this code inside your loop:

Expand|Select|Wrap|Line Numbers
  1. total += sales[row][col];
If I understand correctly, you don't want to do this if
sales[row][col] is less than 1000. Maybe:

Expand|Select|Wrap|Line Numbers
  1. if (sales[row][col] >= 1000)
  2. {
  3.      total += sales[row][col];
  4. }
If I have misunderstood, please post again.

2 1232
weaknessforcats
9,208 Expert Mod 8TB
You have this code inside your loop:

Expand|Select|Wrap|Line Numbers
  1. total += sales[row][col];
If I understand correctly, you don't want to do this if
sales[row][col] is less than 1000. Maybe:

Expand|Select|Wrap|Line Numbers
  1. if (sales[row][col] >= 1000)
  2. {
  3.      total += sales[row][col];
  4. }
If I have misunderstood, please post again.
Aug 4 '13 #2
Thank you so much! Works like a charm!
Aug 4 '13 #3

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

Similar topics

8
by: Dynamo | last post by:
Looking for a function to split numbers into an array for use in a simple graphical counter. Objective: $count = 12345 //want to end up with $array=1 $array=2 $array=3 //and so on then I can...
9
by: Lance Hoffmeyer | last post by:
Is there an easy way to round numbers in an array? I have Test = and want to round so the values are print Test
5
by: Bint | last post by:
Hi, I have an array of numbers, and I need to turn it into a single binary string. How do I do that? Thanks B
4
by: spareforme | last post by:
Hi, fairly new to C programming. I have been asked to generate a list of numbers and store the prime ones in an array so that they can be then later printed out in columns. My generateprime...
1
by: 6Aakaye | last post by:
hope some oe can help me with this programe. our instructor wants us 2 write a C programme that inputs a 12 number in an array.
5
by: k4m135h | last post by:
Hi, I've come across a problem where i seem to be doing the counting of numbers in a inefficient way i've got a 200x200 array with numbers ranging from 101-600 and also 0 and 1. and i need to count...
8
by: edgy | last post by:
First off, my skill level is beginner/intermediate. I know how to use php/mysql to fill in a page with information, but I read a little about arrays and i think this may be an interesting and...
4
shashankraj1231
by: shashankraj1231 | last post by:
I am trying to write a Java program in which we would take input from the user until the user enters -1. The input would be integers and has to be stored in a integer array. I am a newbie in...
3
by: aeroranger | last post by:
Hi all, My file has characters and numbers in the format given below: # 1 2 3 4 5
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.