Hewlett-packard Compaq presario cq60-420...

modulo, if i'm not mistaken, is fancy word for "remainder after integer division". so, 0 div by 3 is zero. the remainder is 3.

modulo is short-handed as %, which can lead to confusion considering windows' use of the percent sign. But your submitted equation is: 0 % 3 and therefore yields 3 as the remainder from the division. any further elucidation will require math courses, not programming. good luc.

Thanks for your reply. I would like to create a C program to reverse the number entered by user. Here's what I have done. Is this the correct logic ? 1. #include<stdio.h>

2. #include<conio.h>

3. void main()

4. {

5. int x,y,z;

6. scanf("%d",&x);

7. while(x>0)

8. {

9. y=x/10;

10 z=x%10;

11. x=y;

12. printf("%d",z);

}

math class LOL

Modulo is a fancy name for modulo. And zero mod anything is zero.

=====================================

Helping others achieve escape felicityM2

I always thought 0 % 3 == 0. Who said it == 3 ?

(red face) apologies. my logic wrong. not enough math\computer classes or too long since. Hoist on mey own petard Oi is. LOL . #include<stdio.h>

2. #include<conio.h>

3. void main()

4. {

5. int x,y,z;

6. scanf("%d",&x);

7. while(x>0)

8. {

9. y=x/10;

10 z=x%10;

11. x=y;

12. printf("%d",z);

}my understanding is: for each digit in number, reflect the 10's complement (ie: 10 minus digit): 183 = 927 674 = 436 etc.

but i'm probl'y wong. (seems to be a trend lately.)

if you are fielding successive digits by division,

you would need to:

C = 0

OUT = 0

do while num>0

'capture first digit in A and strip from number

A=num % 10

num = num - A

'shift the main number 1 digit

num = num / 10'reverse (10's-complement) the captured digiit

A = 10 - A

'modulo to make 10=0, 9=1,. etc.

A = A % 10

'exponentiate the digit (1's, 10's, 100's)

A = A* ( C^10 )

C=C+1

OUT = OUT + A

loopsorry about my misinformation about modulo. seems i'm always wrong. take this into acct if using or adapting my code.

I mean numbers entered from 1,but not negative numbers.

It can be 123, so answer should be 321. But when I enter a long number, the answer is not what it should be. Why?

The program that you posted tries to deal with two-digit numbers. It doesn't yet do everything it needs to do to create the reversed number. You need to think a little bit more about exactly how you do this. Concentrate on two-digit numbers first, don't complicate things. Once you have sorted out the two-digit problem, think about how you are going to do it for arbitrarily sized numbers. It will be more complicated, and you will need to start again, but carry over the knowledge and skill you've picked up in your first step.

I don't know why reversing a string would require math. =================================

@echo off & setLocal EnableDELAYedExpansionif %1'==' echo done && goto :eof

set N=

set S=%1:loop

set /a N+=1

set v!N!=!S:~0,1!

if "!S:~1!" neq "" (

set S=!S:~1!

goto :loop

)for /L %%a in (!N! -1 1) do (

set R=!R!!v%%a!

)echo !R!

=====================================

Helping others achieve escape felicityM2

Er, M2, I thought this was a question about reversing an integer

in C++.

Hi klint, I guess you're right.

=====================================

Helping others achieve escape felicityM2

Ask Your Question

Weekly Poll

Would you ride in a self-driving car from Tesla?

Discuss in The Lounge

Poll History