#Write a modular c program to reverse a number
37 messages · Page 1 of 1 (latest)
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.
!hw
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.
How to reverse a number like 456 make it 654
Do you have any idea on how you can do it ?
Yeah I know the solution but idk how it works
do you know the modulo operator? %
what would happen if you did 456 % 10
6
do you think you can work something out with that ?
if you do 456 % 10 you have 6 and if you do 456 / 10 you have 45 right ?
Yes
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
you could probably also use two arrays and a loop
@pine finch I didn't study arrays still
@fierce creek @pine finch can I dm you if I have any other doubts guys?
@trail plover Has your question been resolved? If so, type !solved :)
@fierce creek can you explain me what is the use of return and printf statements
A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions.
You can read those, they explain better than i can
;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);
}
result is : 3