Welcome to HBH! If you had an account on hellboundhacker.org you will need to reset your password using the Lost Password system before you will be able to login.

c++ questions


ghost's Avatar
0 0
  1. What's the difference between int and double?

  2. Why does 12% 5 = 2?

  • thanks

yours31f's Avatar
Retired
10 0

int = intager == a whole # (e.g. 2)

double = a decimal (e.g. 11.1)


Futility's Avatar
:(
80 120

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
  1. 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)


yours31f's Avatar
Retired
10 0

ya cuz the first part is almost exactly what i said.


ghost's Avatar
0 0

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


yours31f's Avatar
Retired
10 0

as far as i can tell it should be

12% 5 = 2

20 % 10 = 0

20 % 21 = 1 <— only thing i could see wrong


ghost's Avatar
0 0

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?


ghost's Avatar
0 0

Nevermind I just understood it.

thanks again :P


Futility's Avatar
:(
80 120

…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.


yours31f's Avatar
Retired
10 0

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)


ghost's Avatar
0 0

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++.


yours31f's Avatar
Retired
10 0

oh good catch i missed that lol


ynori7's Avatar
Future Emperor of Earth
0 0

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?


ghost's Avatar
0 0

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.


Uber0n's Avatar
Member
0 0

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 :p