Fires of Heaven Guild Message Board  

Go Back   Fires of Heaven Guild Message Board > General forums > Development
User Name
Password
ForumSpy Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Old 09-16-2006, 08:23 PM   #1 (permalink)
bcware
Bisous A.S.
 
bcware's Avatar
 
Join Date: Jan 2005
Posts: 548
+0 Internets
c++ retard homework math

i'm taking an intro majors course called "C++", which has way too much theory thrown in and dumbing down of programming. Anyhow, our homework assignments consist of us writing header files that contain statements to manipulate given variables in various ways. Now, this is dumbed down because all variables are given (not declared or defined by me, i see nothing and i can only use them), statements do NOT end with a semicolon. the teacher is using some buttfucking code to pull whatever code you type into his file to use it, so for me it just looks like algebra for the most part.

Now, the problem: "write an expression which will calculate the value of the (integer) tens digit (second digit from the right) of a non-negative integer called "val".

This is more general math than language specific but i have NO clue how to do this so that it works in ALL cases without actually "programming" so to speak (if, else, then...). is this possible? does anyone know how to do it?

for any two-digit number "val / 10" works because it drops the remainder.
for any single digit "val / 10" works because it simply returns 0 which is what he wants it to do.
anything 3 digits or more obviously does NOT work and simply drops the digit in the original ONES part of the number. "2345 / 10 = 234", etc etc...

i THINK i have to do this using basic arithmatic and i don't think i can make any conditional cases.

also, if this is really simple for someone give me a break. i'm a senior biology major. i have experience programming, but i made games and didn't deal with much algebraic problem solving.
__________________
bcware is offline   Reply With Quote
Old 09-16-2006, 09:34 PM   #2 (permalink)
bcware
Bisous A.S.
 
bcware's Avatar
 
Join Date: Jan 2005
Posts: 548
+0 Internets
i figured it out on my own... if anyone cares:

( val % 100 ) / 10

returns the digit in the tens place for any non-negative integer.
__________________
bcware is offline   Reply With Quote
Old 09-17-2006, 01:55 AM   #3 (permalink)
Vinen
A Cat is Fine Too
 
Vinen's Avatar
 
Join Date: Oct 2002
Location: Not in fucking Acton, MA anymore!
Posts: 2,865
mmmm basic programming math.
Vinen is offline   Reply With Quote
Old 09-17-2006, 12:46 PM   #4 (permalink)
Zippygoose
Math Enthusiast/Badass MC
 
Zippygoose's Avatar
 
Join Date: Jun 2002
Location: Seattle
Posts: 611
-1 Internets
Send a message via AIM to Zippygoose
mod FTW.
Zippygoose is offline   Reply With Quote
Old 09-18-2006, 02:23 PM   #5 (permalink)
findar
Registered User
 
findar's Avatar
 
Join Date: Aug 2002
Posts: 3,294
-3 Internets
Send a message via AIM to findar
if you take computer science in college its ALL dumbed down theory.
__________________
-its clobbering time
findar is offline   Reply With Quote
Old 09-18-2006, 02:52 PM   #6 (permalink)
Zippygoose
Math Enthusiast/Badass MC
 
Zippygoose's Avatar
 
Join Date: Jun 2002
Location: Seattle
Posts: 611
-1 Internets
Send a message via AIM to Zippygoose
Quote:
Originally Posted by findar
if you take computer science in college its ALL dumbed down theory.
For the most part I agree. Every once in a while you'll get a fun hands-on class but they are few and far between. To anyone that wants to get started in this field I recommend finding a good internship as soon as possible.
Zippygoose is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are On
uberguilds network



All times are GMT -7. The time now is 03:45 PM.


Powered by vBulletin® Version 3.6.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.0.0 RC6