Forums

Forums (http://www.abandonia.com/vbullet/index.php)
-   Programming (http://www.abandonia.com/vbullet/forumdisplay.php?f=25)
-   -   C++ Mod And Div Equivalents? (http://www.abandonia.com/vbullet/showthread.php?t=7687)

The Fifth Horseman 20-10-2005 01:33 PM

Simple. What are the commands in C++ equivalent in function to Pascal MOD and DIV commands? I need this little detail for a program of mine...

Rinforzando 20-10-2005 03:02 PM

Mod is the percentage sign - %

I don't know if there is one for div, but you can just use the / operator, then disregard the fractional part.

Kon-Tiki 20-10-2005 04:37 PM

If DIV is division (I don't know Pascal, so I'm just going on the shape of the word), you just use / for divisions.

E.G.
x = 10;
x = x/5;
print x;

OUTPUT: 2

NrmMyth 20-10-2005 05:16 PM

Operator / concerning two integers returns an integer.
Expresions:
19/5=3;
19/(5.0)= 3.8;

Data 21-10-2005 07:16 AM

yeps
Code:

19/5 = 3
19%5 = 4


The Fifth Horseman 21-10-2005 12:48 PM

Thanks people. You're real lifesavers...


The current time is 07:12 PM (GMT)

Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.