Calculation with operators [closed] - c++

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I know this looks like homework, but it isn't.
Please develop a program which could take in 5 ints (from 1 to 9), and use +, -, *, /, (, ) these operators to calculate at least one equation to make the result = 24. The operators, you do not need to use all of them, and also, you could use each of them as many times as you want.
For example, if user put in 3, 8, 1, 1, 1 to your program, the result should be:
3 * 8 / 1 / 1 / 1 = 24
I don't want the actual solution to this, but could someone please give me some starting tips?

could someone please give me some starting tips?
Tip #1:Get started. It doesn't matter that you don't know how to write this program, just write the simplest program you can to get started and then build from there. You can write Hello World, right? Do that. Do you know how to accept input from the user? Add that. Building a program that can accept input and print output will get you significantly further than you are now.
Tip #2: Break it down. Instead of worrying about how to accept five integers and operators, can you do two? Or maybe just accept two integers and print their sum to start. Once you're that far, you'll have a much better sense of what you'd need to do to accept operators and more numbers.
Tip #3: Ask for help (at the right time). Right now, you don't have anything done at all, so everything seems overwhelming. You can't even sort out what you know from what you don't know, so you don't know enough to ask a good question. Once you get started, you'll start to home in on the things you really don't know. Those things will be much better defined at that point, and you'll be able to do a more focussed search for solutions. Chances are, someone has already asked questions about the same things you don't understand, and you'll be able to find those questions once you know what to focus on. If not, you'll be able to ask a much more specific question that provides enough details to let someone help you. Those are exactly the kinds of questions that tend to get up votes and good answers, and (more importantly) really help you learn something.
Tip #4: Forget the computer. Try solving the problem with index cards, where each card represents some piece of data, like a number or an operator. Sometimes this helps you see how the data should be organized in order to solve the problem. Solving a problem in the real world helps you develop a mental model for solving it in code.

Related

Ecology C++ Code [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
New to C++ and stuck on how to start coding this problem which is an Ecology question at first to start a cell with plants antelopes and tigers. Based on initial population, birth rates, food supply, dying off and migration into other cells (once 1 cell is discovered then can expand more). Did some tests on paper to see that plants are going to need a Cap because plants multiply more than antelopes can eat them. I dont really know how to start this if anyone can give me a starting point then that will be grateful.
Thank you.
I sounds like you're trying to build an individual, agent-based, or microscale model: this being subsets of the more general topic of discrete event simulation. Looking into those topics and reading some of the literature and books around them would be a good start.
One way to get started conceptually might be to play with SimPy. Once you think you understand how its pieces fit together and how to build a model, you'll be in a better position to move to a higher-performance language, like C++, where you'll need to build more of the components yourself.
You should also learn how to program. Having to ask a question as general as you are at the beginning of this endeavour should give you pause: people have devoted careers figuring out how to do this the right way. That said: C++ is a decent choice of language because you'll need to run your model not just once, but tens of thousands of times, in order to get an idea of how variable your results are. Remembering that the number of interactions between variables grows exponentially in the number of variables, you'll also want to explore different combinations of environments with an eye to testing the strength of your assumptions.
All of this will also probably require the use of a high-performance environment: you'll want to learn about MPI, R's HPC packages, jug, or Spark: each of which would have to be tamed to work with your implementation of the model.
This paper I recently published has a relatively simple agent-based model, along with an analysis and source code, which might help you get started. It may also help you understand the enormity of the undertaking you propose.

The importance of estimation [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I'm a beginner in programming and I'm studying C++ using Programming principles and practice using C++. Today Now I'm studying the chapter about the errors and in one paragraph the author explains the importance of estimation, but I have a problem because I cannot understand why estimation ( remember that I have just 2 months of experience in programming ) is so important.
Let me explain in a better way :
To give me an example of estimation the author makes an example where we have to imagine that he wrote a program that calculates the driving distance between two cities, and we want to know whether a given value is reasonable, for example: is a reasonable driving time of 15 hours between New York and Denver? Obviously to come to a conclusion we need to know the distance (looking on the web) between New York and Denver.
My question is: why can not we just check on the web if the result of our program is that correct? Why make estimates appears to be so important? Why the author states that make estimates can avoid us a lot of wasted time and confusion?
Because sometimes you cannot look things up on the web. Imagine a sales management app that calculates the discount on a sale. You cannot google that to find the answer. But if you write the app and it returns a discount of 10,000,000$ on an order of 100$ then that's probably wrong.
What he is really saying is that you will write much better programs if you understand the problem domain, ie you understand what its supposed to do
Imagine being asked to write a program that computes the frunk ratio of the splidge grouters given that each froop has 12 enzags. Is 42 a good answer? Many times I have seen devs in this situation - they have 0 idea of what the program is actually doing and so cant tell if they are writing junk

Style and Enumerators [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
So, in the process of taking a data-structures class (in C++), my professor wanted us to manipulate a linked list of playing cards. That doesn't matter however, what I am interested in is why she did not use an enumerator to represent the suites.
In her code, she used strings to hold the suite of a card. This seemed inefficient because she wanted us to sort them based on suite, under the circumstances, it would have been considerably easier if she had used an enumerated type instead of a string. The string did not offer any help either, because in printing the suite, she output a Unicode character, roughly doubling the length of her function, simply because she did not use an enum.
Is there any reason for her to have done this, or does she simply have strange preferences when it comes to code style?
If you really want to know what your professor's reasoning is, you have to ask your professor. I can only speculate.
But if I were to speculate, I would guess that there are two possible reasons why your professor chose to use strings as descriptors for these attributes.
She is trying to keep the code simple and easy for newbie C++ programmers to understand. Whether the means meet the goal is debateable.
(Personal bias alert) Professors and others in academia, with no real-world experience, often do and teach things that I would consider to be highly sub-optimal.
My guess would be that she either had not considered that approach or that she wanted to test your ability to work with sorting strings.
Code examples might help in that they might clarify what she did and what you think she should have done.
The likely answer is that she just didn't think about the problem she was using to demonstrate whatever she is trying to teach you. That is, she wanted you to focus on sorting (for example), and probably took some code written by someone else and just adapted it to that purpose without much thought.

Ideas for storing and operating on huge numbers in C++ [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
I am supposed to build a program for storing and handling huge integers. I know that there are many answers out there but I need ideas that I can implement easily, bearing in mind that I can use any of the basic concepts of C/C++.
How should I go about it?
This is the first time I am asking a question here so please correct me if I am wrong about anything.
Edit: Actually what I wanted to know was how should I go about storing a huge integer... Obviously an array is what comes to mind at first glance but are there any other methods out there at the basic level?
EDIT2: I came across a very nice solution to this problem a while ago, but was just a bit lazy to put it on here. We can use the concept of number systems to deal with huge numbers. We can declare an array that holds the co-efficient of powers of 256, thus obtaining a base 256 system. We can then use fundamental concepts like those of the various number systems to obtain our required results.
Matt McCutchen has a Big Integer Library
If you want to do this yourself his code would be a great starting point. As you can overload arithmetic operators in C++ it is not too difficult to make a new BigInteger class and make this handle any number of bits per integer.
There is also a stack overflow answer to this question: here
I consider this as a question about theory, as such I suggest to browse the internet using the right keywords for documents/articles or to take a sneak peek at libraries that are implementing this feature and are well tested, this projects also tend to offer a mailing list or a forum where developers can communicate, it can be a good place to start writing about this stuff.

Finished Study, Any tips? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 12 years ago.
Improve this question
Hi finished doing 3 IT diplomas, I have customer service experience, have just started an open source project and will be joining some others already going...
Had anybody got any other hot tips on how to get my foot in the door with a programming job?
Anything, be creative with your answer... or don't be... anything will be good from someone already programming for work...
Cheers folks, Hope you're having a good one :)
firstly question yourself, why do you want to get into programming? what is it about programming that motivates you?
then ask yourself if you were given a choice between a programming job and a job doing something other than programming, how much would you want to do the programming job?
once you know the answers to those questions, getting a job won't be a problem.
it is a matter of motivation. you sound somewhat motivated to me since you are doing OSS work (keep it up).
i've been programming for the last few years, but starting to get the jaded feeling, and losing the motivation, so will probably move to a different field at some point soon, then look into whether it was a sincere desire to understand programming or just doing the work to pay the bills.
remember there are always companies out there looking for good programmers, so it's not a matter of if but when you will get a job, so be a bit picky if you know you have the skillz.
also don't take yourself too seriously. make sure you have fun. if you're not having at least some fun in programming, do something else.
I would suggest the following:
Write an appealing resume/CV
Use internet job sites such as www.jobserve.com and www.monster.com
Investigate companies in your area who might be recruiting
Get and read a copy of "What color is your parachute!"
I think times are perhaps a bit tougher these days but I found my first programming job during the dot-com bust back in the early 2000s so if its anything like back then there are still plenty of jobs around...
Hope this helps!
nick.