#Write a modular c program to reverse a number

37 messages · Page 1 of 1 (latest)

trail plover
#

Draw a memory mapping diagram for it also

next folioBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

fierce creek
#

!hw

next folioBOT
# fierce creek !hw
Luken
We Don't Do Your Homework

Welcome to Together C & C++ :wave:

We won't do your homework for you (#rules) but we are happy to help you learn and point you in the right direction.

Please send what you have so far and ask a specific question.

fierce creek
#

still the same here

#

what do you need help with exactly? what did you try?

trail plover
#

How to reverse a number like 456 make it 654

fierce creek
#

Do you have any idea on how you can do it ?

trail plover
#

Yeah I know the solution but idk how it works

fierce creek
#

do you know the modulo operator? %

trail plover
#

Yes

#

Gives remainder

fierce creek
#

what would happen if you did 456 % 10

trail plover
#

6

fierce creek
#

do you think you can work something out with that ?

trail plover
#

Next idk

#

Please tell me the full logic

fierce creek
#

if you do 456 % 10 you have 6 and if you do 456 / 10 you have 45 right ?

trail plover
#

Yes

fierce creek
#

you can create a new number using 6

#

then if you do 45 % 10 you'll get the 5
you can put it after 6 to get 65

#

i think you should see where this is going

#

try to implement something like that and comeback with code

pine finch
#

you could probably also use two arrays and a loop

trail plover
#

@pine finch I didn't study arrays still

#

@fierce creek @pine finch can I dm you if I have any other doubts guys?

fierce creek
#

you can just tag us here later

#

don't close the post

trail plover
#

Ok actually tomorrow I have exam

#

Thankyou

next folioBOT
#

@trail plover Has your question been resolved? If so, type !solved :)

trail plover
#

@fierce creek can you explain me what is the use of return and printf statements

fierce creek
fierce creek
#

;compile

#include "stdio.h"

int add(int a, int b)
{
  return a + b; // return the value of a + b to the caller
}

int main()
{
  int result = add(1, 2); 
  printf("result is : %d", result); 
}
polar isleBOT
#
Program Output
result is : 3