couple quick questions

I am studying for my C++ test that is coming up later this week and I am a little confused on two of the review questions. Hoping someone is able to give me a little help.

The first question reads as follows:

The following is supposed to filter out any value outside the range


 
 if ( t >= 35 || t <= 67 )


The second question that has me a little confused reads as follows:

The statement with the arrow is an example of what term (not assignment)? How does it illustrate that term?

1
2
3
4
float f;
int i = 3;
f = i; <--


Thanks in advance for whoever has the time to help me out.
For the first question, read it back out-loud:

If t is greater-than or equal 35,

or

t is less than or equal to 67.

That might help you. I hope so!
ahh yes now i feel stupid haha thanks kooth.

anyone know about the second question?
You're welcome: Don't feel stoopid: That's MY job! It is often helpful to say the code out loud or write it down like a word problem -- at least for me it is.

As for the second question, I know that most modern compilers will throw an error when assigning an int to a float (without a cast). Other than that, I got no clue!

Good luck!
Hi,

The second one is an implicit cast, by the type conversion rules, the int is cast to a float.

This cast to a wider type is not an error or even a warning, but conversely a narrowing of type (float to int or double to float say) might attract a warning - if one has that warning turned on.

Reading the compiler manual is worthwhile, if one can put up with the tediousness of it. The gcc (g++) manual has a zillion options with regard to warnings / errors , there are some that are not enabled by -Wall -Wextra -pedantic

A definition of stupid is when one knows something doesn't work, but tries it again anyway. So this is quite different to not knowing how something works in the first place :+D

Good Luck!!
@TheIdeasMan: That's right! Duh! Thanks for setting the record straight on the second one, and that was very nice of you to encourage the OP! Well, done, sir!
Topic archived. No new replies allowed.