Hey, Beth, you have been very patient. I think many of the answers on this thread have been unnecessarily harsh to you.
There is a reason for that, however. Programmers are not typically your normal kind of social type, and they can be very rude, especially when they perceive that you have not been trying to use your brain or that you are simply begging solutions.
Like any discipline, programming requires study and effort, and in particular:
exactness.
That is part of the conflicting things people have posted here, such as complaining about lack of headers or errors with size_t and the like. You really don’t have to care about that — just follow the question exactly.
For example:
1. Given an integer ‘a’ and an integer ‘b’ write an IF statement that executes when ‘a’ is less than 5 and ‘b’ is greater than or equal to 22. |
I know that an IF statement looks like:
if (some_condition)
I can check that ‘a’ is less than 5 with the ‘<’ operator:
(a < 5)
.
Likewise, I can check that ‘b’ is greater-than or equal-to 22:
(b >= 22)
.
I can check that
both are true (make note of the use of the word “and” in your problem statement) with the ‘&&’ operator:
(a < 5) && (b >= 22)
.
Put this condition into your IF statement and you are done:
if ((a < 5) && (b >= 22))
Final answer.
The purpose of these kinds of homework are to help you study basic materials so that you can pass your exams, proving that you understand the material.
If you have not been paying attention in class, or have been overwhelmed, take a night or two and just work your way through the book, studying examples and using your very excellent brain to figure out what the examples mean and how to express the ideas in the C++ language.
As an anecdote, when I took my first semester of calculus, I wasn't sure I quite understood everything. I was doing the homework, playing with limits (not really understanding them, but hey, trying to keep up), and I remember one day in the middle of the week sitting in class when the conversation suddenly went over my head. I wondered if I had fallen asleep for five minutes or something. I had to take the course over.
Turns out that calculus is actually really easy (really!), but it requires some effort to bend your brain around the concepts. (Which I think are often taught in a mind-bogglingly unintuitive way, BTW.)
The same thing happens in CS. It takes a bit to get your brain to wrap around the concepts and thinking in a much more strict, logical way. But you can do it. Your brain is more powerful than any computer, anywhere. (Just not as fast, which is why we like computers. --And we can’t do telepathy, so computers help there, too... with wireless communication, and stuff...)
All the things you have been asked to do are very basic concepts. Look through your notes. Peruse the first few chapters of your textbook — variables and expressions and loops — and if your final exam is in a few weeks you’ve got time to put in a few hours a week to get it.
Good luck!
[edit] Fixed typo