| Author |
c++ questions |
Rever
Member

Posts: 40
Location:
Joined: 24.05.07 Rank: Newbie |
|
1) What's the difference between int and double?
2) Why does 12% 5 = 2?
- thanks
"Insert signature here" |
|
| Author |
RE: c++ questions |
yours31f
Second to one

Posts: 1678
Location: Dallas Texas
Joined: 27.04.07 Rank: Satan |
|
int = intager == a whole # (e.g. 2)
double = a decimal (e.g. 11.1)
Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.

|
|
| Author |
RE: c++ questions |
Futility
Member

Posts: 715
Location: USA
Joined: 17.12.07 Rank: God |
|
You might want to try researching a little by yourself before posting but, since I'm ecstatic that I know the answer, I'm going to try and help.
1) What's the difference between int and double?
int is only real counting numbers. IE: 1,2,3,4 etc
dbl is all the numbers in between. IE: 1.2, 1.3, 1.4 etc
2) Why does 12% 5=2?
% is the way C++ displays modulous. I don't really know how to explain it other than saying it's the remainder. 5 goes into 12 2 times (10) with 2 left over. Thus 12% 5=2. If you know any VB, it is the same as MOD.
Hope I helped. If I'm wrong about modulous, feel free to correct me. (I don't think I am)
|
|
| Author |
RE: c++ questions |
yours31f
Second to one

Posts: 1678
Location: Dallas Texas
Joined: 27.04.07 Rank: Satan |
|
ya cuz the first part is almost exactly what i said.
Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.

|
|
| Author |
RE: c++ questions |
Rever
Member

Posts: 40
Location:
Joined: 24.05.07 Rank: Newbie |
|
Okay, thanks.
so if I was using " double a, double b; " then it would mean a and b have a decimal in them?
These are the problems I have and the answers. But I don't know how they got them.
12% 5 = 2
20 % 10 = 0
20 % 21 = 20
"Insert signature here" |
|
| Author |
RE: c++ questions |
yours31f
Second to one

Posts: 1678
Location: Dallas Texas
Joined: 27.04.07 Rank: Satan |
|
as far as i can tell it should be
12% 5 = 2
20 % 10 = 0
20 % 21 = 1 <--- only thing i could see wrong
Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.

|
|
| Author |
RE: c++ questions |
Rever
Member

Posts: 40
Location:
Joined: 24.05.07 Rank: Newbie |
|
I'm studying for my final tomorrow and there's the question and an answer key.
It says 20 but the 0 was written sloppy and looks like a 1 turned into a 0. I don't know...
So why do first two come out to equal that?
"Insert signature here" |
|
| Author |
RE: c++ questions |
Rever
Member

Posts: 40
Location:
Joined: 24.05.07 Rank: Newbie |
|
Nevermind I just understood it.
thanks again 
"Insert signature here" |
|
| Author |
RE: c++ questions |
Futility
Member

Posts: 715
Location: USA
Joined: 17.12.07 Rank: God |
|
...Didn't I just explain this? Ok, I'm sure it was unclear and/or confusing.
% finds the remainder- the leftovers, if you will.
5 goes into 12 how many times?
2.
5*2=10.
12-10=2.
12%5=2.
@Yours3lf
Maybe-just maybe, I started writing my answer before you, but took the time to be thorough and check my spelling, allowing you to post your crap before me? Nah, that's not possible. I must have just copied your beautiful answer.
|
|
| Author |
RE: c++ questions |
yours31f
Second to one

Posts: 1678
Location: Dallas Texas
Joined: 27.04.07 Rank: Satan |
|
your welcome. if you need anymore help pm. (i took a class in java and css ,just wish that it wouldv'e been with js)
Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.

|
|
| Author |
RE: c++ questions |
Zephyr_Pure
Member

Posts: 2402
Location:
Joined: 15.09.06 Rank: God |
|
|
yours31f wrote:
as far as i can tell it should be
20 % 21 = 1 <--- only thing i could see wrong
Why on earth would the remainer of 20 divided by 21 be 1? 21 goes into 20... 0 times, with a remainder of 20.
Other than that, decent explanations on double vs. int and modulus... as a further course of action, I would suggest a book on beginning C++.
I still check PMs from time to time.


Our responses were moronic, why shouldn't he follow suit? - Futility |
|
| Author |
RE: c++ questions |
yours31f
Second to one

Posts: 1678
Location: Dallas Texas
Joined: 27.04.07 Rank: Satan |
|
oh good catch i missed that lol
Debugging is what programmers do to beta software to make it take up more room on your hard drive if it is running too efficiently.

|
|
| Author |
RE: c++ questions |
ynori7
Future Emperor of Earth

Posts: 1481
Location: #valhalla
Joined: 08.10.07 Rank: Diabolical |
|
like someone mentioned before, use google first before asking for help. these questions could have easily been answered with a simple google search.
also, i'm curious as to why you waited until the day before the final to understand these simple concepts. what class is this final for?
|
|
| Author |
RE: c++ questions |
dex_poet
Member

Posts: 367
Location:
Joined: 25.11.07 Rank: Wiseman |
|
Go to the microsoft home page. Then browse to the C++ video training. They start off with basic syntax and basic logic.
Better get to work if your final is in C++...
EDIT: whoops. I thought you said somewhere it was C++, but it turns out it was Zephyr_Pure's post. microsoft will still get you through what you need though.
Edited by dex_poet on 25-01-08 04:21 |
|
| Author |
RE: c++ questions |
Uber0n
Member

Posts: 1963
Location: Sweden
Joined: 13.06.06 Rank: God |
|
|
Zephyr_Pure wrote:
Why on earth would the remainer of 20 divided by 21 be 1? 21 goes into 20... 0 times, with a remainder of 20.
Thanks, now I didn't have to explain this myself 

http://uber0n.webs.com/ |
|